source: FOIAVistA/trunk/r/PAID-PRS/PRSRLL.m@ 1437

Last change on this file since 1437 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.7 KB
Line 
1PRSRLL ;HISC/JH-CALCULATE LENGTH OF TIME ;7-AUG-2000
2 ;;4.0;PAID;**2,6,21,61**;Sep 21, 1995
3 ;This routine is called by ^PRSRL11,^PRSRL12,^PRSRL41.
4H ; Calculate Hours
5 N %,DAY,X,X1,X2,D1,PPE,Y,K S TYL="H",D1=$P(Z,"^",3) D PP^PRSAPPU
6 I D1=$P(Z,"^",5) G 1
7 ; Calculate first day
8 D TC S X1=$G(^PRST(457.1,+TC,1))
9 S X2="MID" F K=1:3 Q:$P(X1,"^",K)="" S %=$P(X1,"^",K+2) I $S('%:1,1:$P($G(^PRST(457.2,%,0)),"^",2)="RG") S X2=$P(X1,"^",K+1)
10 S X=$P(Z,"^",4)_"^"_X2 D CNV S TIM=$P(Y,"^",2)-$P(Y,"^",1)/60 S:TIM<0 TIM=0
11 D RG I TIM>RG S TIM=RG
12 E S X1=$P(X1,"^",3) I X1,TIM>4.75 S TIM=TIM-(X1/60)
13 ; Calculate intermediate days
140 S DAY=DAY+1 S:DAY=15 DAY=1,PPI=$S('PPI:PPI,$D(^PRST(458,PPI+1)):PPI+1,1:"")
15 S X1=D1,X2=1 D C^%DTC S D1=X I X'<$P(Z,"^",5) G L
16 D TC,RG S TIM=TIM+RG G 0
17L ; Calculate last day
18 D TC S X1=$G(^PRST(457.1,+TC,1))
19 S X2="MID" F K=1:3 Q:$P(X1,"^",K)="" S %=$P(X1,"^",K+2) I $S('%:1,1:$P($G(^PRST(457.2,%,0)),"^",2)="RG") S X2=$P(X1,"^",K) Q
20 S X=X2_"^"_$P(Z,"^",6) D CNV S T1=$P(Y,"^",2)-$P(Y,"^",1)/60 S:T1<0 T1=0
21 D RG I T1>RG S T1=RG
22 E S X1=$P(X1,"^",3) I X1,T1>4.75 S T1=T1-(X1/60)
23 S TIM=TIM+T1 K AC,FLX,NH,T1 Q
241 ; One Day
25 S X=$P(Z,"^",4)_"^"_$P(Z,"^",6) D CNV
26 I $P(Z,"^",4)["P"&($P(Z,"^",6)["A") S TIM=((1440-$P(Y,U))/60)+($P(Y,U,2)/60)
27 E S TIM=$P(Y,"^",2)-$P(Y,"^",1)/60
28 S:TIM'>0 TIM=TIM+24 ;This line of code relocated to correct miscalculation - refer to Patch PRS*4*61
29 D TC,RG I TIM>RG&($P(X4,"^",13)'="") D SEC I TIM>RG S TIM=RG Q
30 I TIM>RG S TIM=RG
31 ;Algorithm to determine whether to deduct lunch. Deduct lunch from
32 ;leave only when leave taken is >= length of tour + meal time.
33 I $P(TOUR,"^",5)'="" D
34 . S LEN=$P($G(^PRST(458,PPI,"E",D0,"D",DAY,0)),"^",8)
35 . I (LEN+LUN)<TIM S TIM=(TIM-(LUN/60))
36 Q
37TC ; Get tour
38 I PPI S X1=$G(^PRST(458,PPI,"E",D0,"D",DAY,0)),X4=X1,TC=$P(X1,"^",2)
39 E S PPI=$P(^PRST(458,0),"^",3),X1=$G(^PRST(458,PPI,"E",D0,"D",DAY,0)),X4=X1,TC=$P(X1,"^",2) I $P(X1,"^",3),$P(X1,"^",4) S TC=$P(X1,"^",4)
40 Q
41RG ; Get X1,RG
42 S X1=$G(^PRST(457.1,+TC,0)),LUN=$P(X1,"^",3),RG=$P(X1,"^",6) Q:RG'="" I TC<5 S RG=0 Q
43 I $E(AC,2)=1,NH=48 S RG=12 Q
44 S RG=$S(NH>80:24,NH<80:8,FLX="C":10,1:8) Q
45D ; Calculate Days
46 N %,K S X2=$P(Z,"^",3),X1=$P(Z,"^",5) I 'X1!('X2) Q
47 D ^%DTC S TIM=X+1,TYL="D"
48 Q
49CNV ; Convert Start/Stop to minutes
50 ; X=start_"^"_stop Output: Y=start(min)_"^"_stop(min)
51 S CNX=X,X=$P(CNX,"^",1),Y=0 D MIL S Y=Y\100*60+(Y#100),$P(CNX,"^",1)=Y
52 S X=$P(CNX,"^",2),Y=1 D MIL S Y=Y\100*60+(Y#100)
53 S Y=$P(CNX,"^",1)_"^"_Y K CNX Q
54MIL ; Convert from AM/PM to 2400
55 ; X=time Y: 0=Mid=0,1=Mid=2400 Output: Y=time in 2400
56 I X="MID"!(X="NOON") S Y=$S(X="NOON":1200,Y:2400,1:0) Q
57 S Y=$P(X,":",1)_$P(X,":",2),Y=+Y Q:X["A"
58 S:Y<1200 Y=Y+1200 Q
59SEC S TC=$P(X4,"^",13) D RG Q
Note: See TracBrowser for help on using the repository browser.