PRSATD1 ; HISC/REL-Edit/Display Tour of Duty ;8/12/94 10:10
;;4.0;PAID;;Sep 21, 1995
EDIT ; Enter/Edit Tour of Duty
D HDR K DIC
S DIC="^PRST(457.1,",DIC(0)="AEQLMN",DLAYGO=457.1,DIC("A")="Select TOUR OF DUTY: ",DIC("S")="I +Y>9" D ^DIC K DIC G:Y'>0 EX S TDI=+Y
S ZN=$G(^PRST(457.1,+Y,1)),DA=+Y,DDSFILE=457.1,DR="[PRSA TD EDIT]" K ZS D ^DDS K DS
I $D(ZS) S ^PRST(457.1,DA,1)=ZS,TIM=TIM-$P(^(0),"^",3)/60,$P(^(0),"^",6)=$S(TIM>0:TIM,1:0)
I '$D(^PRST(457.1,DA,1)) S DIK="^PRST(457.1," D ^DIK G EX
I '$P(^PRST(457.1,DA,0),"^",4) S DDSFILE=457.1,DR="[PRSA TD TL]" D ^DDS K DS
G EDIT
NAM ; Verify Tour Name format
S %=X,X=$P(%,"-",1) D ^PRSATIM Q:'$D(X) S $P(%,"-",1)=X
S X=$P(%,"-",2),X=$P(X," ",1) D ^PRSATIM Q:'$D(X)
S X=$P(%,"-",1)_"-"_X I $P(%," ",2,99)'="" S X=X_" "_$P(%," ",2,99)
K % Q
VAL ; Shuffle segments
K T,ZS S TIM=0,TWO=$$GET^DDSVAL(DIE,DA,5),DY2=TWO="Y",MEAL=$$GET^DDSVAL(DIE,DA,2)/60
F K=1:3:19 S X=$P(ZN,"^",K) I X'="" S X=X_"^"_$P(ZN,"^",K+1) G:$P(ZN,"^",K+1)="" E7 D CNV^PRSATIM S Z1=$P(Y,"^",1),Z2=$P(Y,"^",2) D V0 G E3:$D(T(Z1)),E4:TWO'="Y"&(Z2>1440),E5:Z2>2880 S T(Z1)=Z2_"^"_$P(ZN,"^",K,K+2) D V1
S Z1="" F S Z1=$O(T(Z1)) Q:Z1="" G:Z1'<T(Z1) E1 S Y=$O(T(Z1)) I Y,T(Z1)>Y G E2
S Z1="",K=1 F S Z1=$O(T(Z1)) Q:Z1="" S $P(ZS,"^",K)=$P(T(Z1),"^",2),$P(ZS,"^",K+1)=$P(T(Z1),"^",3) S:$P(T(Z1),"^",4)'="" $P(ZS,"^",K+2)=$P(T(Z1),"^",4) S K=K+3
G:'$D(ZS) E6 G:MEAL>TIM E8 Q
V0 I Z2>Z1 S:DY2=1&($O(T(0))>Z1) DY2=2 I DY2=2 S Z1=Z1+1440,Z2=Z2+1440
S:Z2'>Z1 Z2=Z2+1440,DY2=2 Q
V1 I $P(ZN,"^",K+2),"RG"'[$P($G(^PRST(457.2,+$P(ZN,"^",K+2),0)),"^",2) Q
S TIM=TIM+Z2-Z1 Q
E1 S STR="A start time is not less than a stop time." G E10
E2 S STR="End of one segment must not be greater than start of next." G E10
E3 S STR="Duplicate start times encountered." G E10
E4 S STR="Segment of second day encountered; no two-day tour specified." G E10
E5 S STR="Segment of third day encountered." G E10
E6 S STR="At least one time segment must be defined." G E10
E7 S STR="Stop Time not entered for a segment." G E10
E8 S STR="Meal period cannot exceed duty hours." G E10
E10 K ZS S DDSERROR=1,TIM=0 D HLP^DDSUTL(.STR) Q
DISP ; Display Tour of Duty
D HDR K DIC
S DIC="^PRST(457.1,",DIC(0)="AEQMN",DIC("A")="Select TOUR OF DUTY: " D ^DIC K DIC G:Y'>0 EX
S DA=+Y,DDSFILE=457.1,DR="[PRSA TD DISP]" D ^DDS K DS G DISP
HDR ; Header
W:$E(IOST,1,2)="C-" @IOF W !?26,"VA TIME & ATTENDANCE SYSTEM",!!?33,"TOUR OF DUTY",!!! Q
EX G KILL^XUSCLEAN
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRSATD1 2494 printed Oct 16, 2024@18:25:09 Page 2
PRSATD1 ; HISC/REL-Edit/Display Tour of Duty ;8/12/94 10:10
+1 ;;4.0;PAID;;Sep 21, 1995
EDIT ; Enter/Edit Tour of Duty
+1 DO HDR
KILL DIC
+2 SET DIC="^PRST(457.1,"
SET DIC(0)="AEQLMN"
SET DLAYGO=457.1
SET DIC("A")="Select TOUR OF DUTY: "
SET DIC("S")="I +Y>9"
DO ^DIC
KILL DIC
if Y'>0
GOTO EX
SET TDI=+Y
+3 SET ZN=$GET(^PRST(457.1,+Y,1))
SET DA=+Y
SET DDSFILE=457.1
SET DR="[PRSA TD EDIT]"
KILL ZS
DO ^DDS
KILL DS
+4 IF $DATA(ZS)
SET ^PRST(457.1,DA,1)=ZS
SET TIM=TIM-$PIECE(^(0),"^",3)/60
SET $PIECE(^(0),"^",6)=$SELECT(TIM>0:TIM,1:0)
+5 IF '$DATA(^PRST(457.1,DA,1))
SET DIK="^PRST(457.1,"
DO ^DIK
GOTO EX
+6 IF '$PIECE(^PRST(457.1,DA,0),"^",4)
SET DDSFILE=457.1
SET DR="[PRSA TD TL]"
DO ^DDS
KILL DS
+7 GOTO EDIT
NAM ; Verify Tour Name format
+1 SET %=X
SET X=$PIECE(%,"-",1)
DO ^PRSATIM
if '$DATA(X)
QUIT
SET $PIECE(%,"-",1)=X
+2 SET X=$PIECE(%,"-",2)
SET X=$PIECE(X," ",1)
DO ^PRSATIM
if '$DATA(X)
QUIT
+3 SET X=$PIECE(%,"-",1)_"-"_X
IF $PIECE(%," ",2,99)'=""
SET X=X_" "_$PIECE(%," ",2,99)
+4 KILL %
QUIT
VAL ; Shuffle segments
+1 KILL T,ZS
SET TIM=0
SET TWO=$$GET^DDSVAL(DIE,DA,5)
SET DY2=TWO="Y"
SET MEAL=$$GET^DDSVAL(DIE,DA,2)/60
+2 FOR K=1:3:19
SET X=$PIECE(ZN,"^",K)
IF X'=""
SET X=X_"^"_$PIECE(ZN,"^",K+1)
if $PIECE(ZN,"^",K+1)=""
GOTO E7
DO CNV^PRSATIM
SET Z1=$PIECE(Y,"^",1)
SET Z2=$PIECE(Y,"^",2)
DO V0
if $DATA(T(Z1))
GOTO E3
if TWO'="Y"&(Z2>1440)
GOTO E4
if Z2>2880
GOTO E5
SET T(Z1)=Z2_"^"_$PIECE(ZN,"^",K,K+2)
DO V1
+3 SET Z1=""
FOR
SET Z1=$ORDER(T(Z1))
if Z1=""
QUIT
if Z1'<T(Z1)
GOTO E1
SET Y=$ORDER(T(Z1))
IF Y
IF T(Z1)>Y
GOTO E2
+4 SET Z1=""
SET K=1
FOR
SET Z1=$ORDER(T(Z1))
if Z1=""
QUIT
SET $PIECE(ZS,"^",K)=$PIECE(T(Z1),"^",2)
SET $PIECE(ZS,"^",K+1)=$PIECE(T(Z1),"^",3)
if $PIECE(T(Z1),"^",4)'=""
SET $PIECE(ZS,"^",K+2)=$PIECE(T(Z1),"^",4)
SET K=K+3
+5 if '$DATA(ZS)
GOTO E6
if MEAL>TIM
GOTO E8
QUIT
V0 IF Z2>Z1
if DY2=1&($ORDER(T(0))>Z1)
SET DY2=2
IF DY2=2
SET Z1=Z1+1440
SET Z2=Z2+1440
+1 if Z2'>Z1
SET Z2=Z2+1440
SET DY2=2
QUIT
V1 IF $PIECE(ZN,"^",K+2)
IF "RG"'[$PIECE($GET(^PRST(457.2,+$PIECE(ZN,"^",K+2),0)),"^",2)
QUIT
+1 SET TIM=TIM+Z2-Z1
QUIT
E1 SET STR="A start time is not less than a stop time."
GOTO E10
E2 SET STR="End of one segment must not be greater than start of next."
GOTO E10
E3 SET STR="Duplicate start times encountered."
GOTO E10
E4 SET STR="Segment of second day encountered; no two-day tour specified."
GOTO E10
E5 SET STR="Segment of third day encountered."
GOTO E10
E6 SET STR="At least one time segment must be defined."
GOTO E10
E7 SET STR="Stop Time not entered for a segment."
GOTO E10
E8 SET STR="Meal period cannot exceed duty hours."
GOTO E10
E10 KILL ZS
SET DDSERROR=1
SET TIM=0
DO HLP^DDSUTL(.STR)
QUIT
DISP ; Display Tour of Duty
+1 DO HDR
KILL DIC
+2 SET DIC="^PRST(457.1,"
SET DIC(0)="AEQMN"
SET DIC("A")="Select TOUR OF DUTY: "
DO ^DIC
KILL DIC
if Y'>0
GOTO EX
+3 SET DA=+Y
SET DDSFILE=457.1
SET DR="[PRSA TD DISP]"
DO ^DDS
KILL DS
GOTO DISP
HDR ; Header
+1 if $EXTRACT(IOST,1,2)="C-"
WRITE @IOF
WRITE !?26,"VA TIME & ATTENDANCE SYSTEM",!!?33,"TOUR OF DUTY",!!!
QUIT
EX GOTO KILL^XUSCLEAN