PRSPESR2 ;WOIFO/JAH - PTP ESR Edit-Calls from ScreenMan Form ;07/28/05
;;4.0;PAID;**93**;Sep 21, 1995;Build 7
;;Per VHA Directive 2004-038, this routine should not be modified.
Q
ELAPSE(MEAL,START,STOP) ; CALCULATE THE HOURS BETWEEN 2 TIMES
;this function is called from ScreenMan Form Computed fields
; file 458 PRSA ESR EDIT form.
N ELAPSE
S ELAPSE=0
Q:($G(START)="")!($G(STOP)="") ELAPSE
S START=$$TWENTY4(START)
;
S STOP=$$TWENTY4(STOP)
; if stop time is next day add a day
I STOP<START!(STOP=START) D
. S STOP=$$FMADD^XLFDT(DT,1,0,0,0)_"."_STOP
E D
. S STOP=DT_"."_STOP
S START=DT_"."_START
S ELAPSE=$$FMDIFF^XLFDT(STOP,START,3)
;for special case of a 24 hour segment
I ELAPSE="1" S ELAPSE="24:00"
;
;Remove any blanks
S ELAPSE=$TR(ELAPSE," ","")
I $G(MEAL)>0 S ELAPSE=$$MEALESS(ELAPSE,MEAL)
S ELAPSE=$$FIVE(ELAPSE)
Q ELAPSE
FIVE(TIME) ;ENSURE ELAPSE IS A FIVE CHAR STRING--04:15 OR 02:00
N FIVE,HH,MM
I $E(TIME,1,1)="-" Q "-00:00"
S HH="00"_$P(TIME,":"),MM="00"_$P(TIME,":",2)
S HH=$E(HH,$L(HH)-1,$L(HH))
S MM=$E(MM,$L(MM)-1,$L(MM))
S MM=$P(TIME,":",2)_"0"
S MM=$E(MM,1,2)
S FIVE=HH_":"_MM
Q FIVE
TWENTY4(TIME) ;CONVERT TIME TO TWENTY FOUR HOUR TIME
;
; TIME Y: 0=Mid=0,1=Mid=2400 Output: Y=time in 2400
S Y=0
I TIME="MID"!(TIME="NOON") D
. S Y=$S(TIME="NOON":1200,TIME="MID":2400,1:0)
E D
. S Y=$P(TIME,":",1)_$P(TIME,":",2),Y=+Y
I TIME["P" D
. S:Y<1200 Y=Y+1200
;
; pad time with leading zeros so we always have 4 digits
; for cases like start times of 15 past midnight 0015
;
S Y="000"_Y
S Y=$E(Y,$L(Y)-3,$L(Y))
Q Y
MEALESS(HHMM,MEAL) ;Remove meal time from hours total
; (subtract a 15 minute increment from length of time
; in hh:mm format, i.e. hh:mm - mm
;
N X,Y,DECR,OBJ,I
S MM=$P(HHMM,":",2) ; get minutes
; quit minutes or meal not quarter hours
Q:(MM#15'=0&(+MM)!((MEAL#15)'=0&(+MEAL))) HHMM
; get hours
S HH=$P(HHMM,":")
;
; convert segment minutes and meal to a digit.
;
S X=MM D MEALIN S OBJ=X
S X=$G(MEAL) D MEALIN S DECR=X
I OBJ=0 S OBJ=4
F I=1:1:DECR D
. I OBJ=4 S HH="0"_(+HH-1) S HH=$E(HH,$L(HH)-1,$L(HH))
. S OBJ=$S(OBJ=4:3,OBJ=3:2,OBJ=2:1,OBJ=1:4)
S MM=$S(OBJ=1:15,OBJ=2:30,OBJ=3:45,1:"00")
Q $$FIVE(HH_":"_MM)
;
MEALIN ;convert 15 minute meal to a digit
I +X#15=0 S X=X\15 Q
I "^0^00^15^30^45^60^75^90^105^120^"[("^"_$G(X)_"^") D
. S X=$S(+X=0:0,X=60:4,X=30:2,X=15:1,X=45:3,1:0)
E D
. K X
Q
MEALOUT ; convert meal digit to minutes
S Y=$S(Y=1:15,Y=2:30,Y=3:45,Y=4:60,1:"00")
Q
;
VALIDTT ; Set DDSERROR if not a valid type of time.
;This procedure is called from ScreenMan form PRSA ESR EDIT (file 458)
;with the validate field of the Type Of Time.
; set DDSERROR to reject user input, then ring bell and
; display a message reject explanation
Q:X=""!($G(PPI)'>0)!($G(PRSIEN)'>0)!($G(PRSD)'>0)
I "^RG^AL^AA^DL^ML^RL^CP^SL^HX^CB^AD^WP^TR^TV^"'[(U_X_U) D
. S DDSERROR=1
. D HLP^DDSUTL("Invalid type of time.")
I "^HX^"[(U_X_U) D
. I $P($G(^PRST(458,PPI,"E",PRSIEN,"D",PRSD,0)),"^",12)'>0 S DDSERROR=1 D HLP^DDSUTL("Holiday Excused is only allowed on a Holiday Benefit Day. See Payroll to set this day as a holiday.")
I $G(PPI),$G(PRSD),$P(^PRST(458,PPI,1),U,PRSD)>$G(DT) D
. I "^AL^AA^DL^ML^RL^CP^SL^HX^CB^AD^WP^TR^TV^"'[(U_X_U) D
.. S DDSERROR=1
.. D HLP^DDSUTL("Invalid type of time. Only leave may be entered on future days")
Q
VALIDLV(SSCH,SPST) ; Set DDSERROR if any posting is outside the
; tour time segements inappropriately
;
;INPUT:
; SSCH : tour segments as scheduled from node 1 of the day multiple
; SPST : tour segments as posted by ptp in T array format
N OK,P1,P2,S1,S2,LV,I,I2,J,MSA,VALIDLV
S (LV,OK,I)=0
S VALIDLV=""
; put tour in similar format as posting
D MARRAY(.MSA,SSCH)
F S I=$O(SPST(I)) Q:I'>0!(LV&'OK) D
. S P1=I,I2=$O(SPST(I,0)),P2=$P(SPST(I,I2),U)
. Q:"^AL^AA^DL^CU^ML^RL^HX^SL^CB^AD^WP^TV^TR^"'[$P(SPST(I,I2),U,4)
. S LV=1,OK=0
. S J=0
. F S J=$O(MSA(J)) Q:J'>0!OK D
.. S S1=J,S2=$O(MSA(J,0)),S2=$P(MSA(J,S2),U)
.. I P1=S1!(P1>S1)&((P2=S2)!(P2<S2)) S OK=1
;
I LV,('OK) S VALIDLV=1
Q VALIDLV
;
MARRAY(MARRAY,SEGS) ; BUILD MINUTE ARRAY
; INPUT : SEGS--tour of duty segments in global format
; OUTPUT: MARRAY--array by reference of tour segments in minutes
; from midnight format
; EXAMPLE:
; 2 segment tour will look like the following:
; MARRAY(945,1)=1140^03:45P^07:00P
; MARRAY(1140,6)=1305^07:00P^09:45P
; MARRAY(1320,11)=1380^10:00P^11:00P
;loop thru the 5 columns of the 7 time segments on ESR
; quit if we encounter an error
;
N I,ANY,Z1,Z2,X,Y
S ANY=1
F I=1:3:21 Q:('ANY) D
. ;
. ;if absolutely nothing on the segment then we're done
. S ANY=$L($P(SEGS,U,I)_$P(SEGS,U,I+1)_$P(SEGS,U,I+2))
. Q:'ANY
. S X=$P(SEGS,U,I)_U_$P(SEGS,U,I+1)
. D CNV^PRSATIM S Z1=$P(Y,U,1),Z2=$P(Y,U,2)
. D V0^PRSATP1
. S MARRAY(Z1,I)=Z2_U_$P(SEGS,U,I,I+2)
Q
PSTML(ROW) ; AUTO POST MEAL TIME
; if the time segment row that we are on in a form covers
; the tour then post a meal.
; ROW - is passed as the
; Z is in the form of NODE 5 in the 458.02 day mult
; it changes with edits on the form
; like Z=09:00A^NOON^RG^^30^NOON^08:00P^RG^^^08:00P^MID^CU^15
;
N RNG,ST2SP,FLDNUM,BASE
Q:$G(PRSML)=""!($G(PRSML)=0)
;
S BASE=ROW-1*5
; quit if something is already in mealtime on the form
Q:$P(Z,U,BASE+5)'=""
; compute the field number of the meal time for this row
S FLDNUM=BASE+114
; get the start TO stop segments for this row of the form
; if it's an exact match then auto post the meal
S ST2SP=$P(Z,U,BASE+1,BASE+2)
I ST2SP=$P($G(PRSN1),U,1,2) D Q
. D PUT^DDSVAL(DIE,.DA,FLDNUM,PRSML)
. D REFRESH^DDSUTL
; get the start TO stop segments for this row of the form
; if it covers the meal and then some autopost the meal
N DY2,TWO,SCHED,POST,SCH,P1,P2,S1,S2
; TOD is a global set up in form start up in ESRFRM^PRSPESR1
S ST2SP=$P(Z,U,BASE+1,BASE+3)
S SCHED=$P($G(PRSN1),U,1,3)
; is this a two day tour? need to check before calling the
; code to set up the minutes array in MARRAY
S TWO=$P($G(^PRST(457.1,+TOD,0)),U,5)
S DY2=TWO="Y"
D MARRAY(.POST,ST2SP)
D MARRAY(.SCH,$P($G(PRSN1),U,1,3))
;get start and stop time minutes form midnight for both
; schedule and posting to determine if meal should be autoposted
S P1=$O(POST(0))
Q:P1'>0
S P2=$P(POST(P1,1),U)
Q:P2'>0
S S1=$O(SCH(0))
Q:S1'>0
S S2=$P(SCH(S1,1),U)
Q:22'>0
I P1'>S1&(P2'<S2) D
. D PUT^DDSVAL(DIE,.DA,FLDNUM,PRSML)
. D REFRESH^DDSUTL
. S $P(Z,U,BASE+5)=PRSML
Q
;
OVEREAT(ROW) ; Display warning on POST ACTION ON CHANGE for the
; meal field on the form if lunch more than allotted for tour
N MTOT,K,BASE,WORK,STR,PRSZ
; When X is null they are trying to delete and that's always ok
Q:$G(Z)=""!($G(ROW)'>0)!($G(X)="")
S BASE=ROW-1*5
;
S WORK=$$ELAPSE^PRSPESR2(X,$P(Z,U,BASE+1),$P(Z,U,BASE+2))
I $E(WORK,1,1)="-"!(WORK="00:00")!(WORK=0) D Q
. S DDSERROR=1
. S STR="Meal time greater than or equal to time segment."
. I X=0 S STR=STR_" Type @ to remove meal time."
. D HLP^DDSUTL(STR)
S MTOT=0
S PRSZ=Z S $P(PRSZ,U,BASE+5)=X
F K=1:5:31 S MTOT=MTOT+$P(PRSZ,U,K+4)
I MTOT>($G(PRSML)+$G(PRSML2)) D
. S STR="Warning: More meal time than allotted with tour."
. D HLP^DDSUTL(.STR)
Q
BURP(PRSN5) ; return ESR WORK NODE with no blank pieces
; PRSN5--esr work node $G(^PRST(458,PPI,"E",PRSIEN,"D",PRSD,5)
; if there's only a meal with a zero then skip that too.
;^^^^^NOON^08:00P^RG^^^08:00P^MID^CU^15
;
N SN,I,TSEG
S SN=""
F I=1:5:31 D
. S TSEG=$P(PRSN5,U,I,I+4)
.; W !,I,": ",TSEG
. Q:TSEG="^^^^"!(TSEG="")!(TSEG="^^^^0")
. S SN=SN_TSEG_"^"
Q SN
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRSPESR2 7889 printed Dec 13, 2024@02:28:05 Page 2
PRSPESR2 ;WOIFO/JAH - PTP ESR Edit-Calls from ScreenMan Form ;07/28/05
+1 ;;4.0;PAID;**93**;Sep 21, 1995;Build 7
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 QUIT
ELAPSE(MEAL,START,STOP) ; CALCULATE THE HOURS BETWEEN 2 TIMES
+1 ;this function is called from ScreenMan Form Computed fields
+2 ; file 458 PRSA ESR EDIT form.
+3 NEW ELAPSE
+4 SET ELAPSE=0
+5 if ($GET(START)="")!($GET(STOP)="")
QUIT ELAPSE
+6 SET START=$$TWENTY4(START)
+7 ;
+8 SET STOP=$$TWENTY4(STOP)
+9 ; if stop time is next day add a day
+10 IF STOP<START!(STOP=START)
Begin DoDot:1
+11 SET STOP=$$FMADD^XLFDT(DT,1,0,0,0)_"."_STOP
End DoDot:1
+12 IF '$TEST
Begin DoDot:1
+13 SET STOP=DT_"."_STOP
End DoDot:1
+14 SET START=DT_"."_START
+15 SET ELAPSE=$$FMDIFF^XLFDT(STOP,START,3)
+16 ;for special case of a 24 hour segment
+17 IF ELAPSE="1"
SET ELAPSE="24:00"
+18 ;
+19 ;Remove any blanks
+20 SET ELAPSE=$TRANSLATE(ELAPSE," ","")
+21 IF $GET(MEAL)>0
SET ELAPSE=$$MEALESS(ELAPSE,MEAL)
+22 SET ELAPSE=$$FIVE(ELAPSE)
+23 QUIT ELAPSE
FIVE(TIME) ;ENSURE ELAPSE IS A FIVE CHAR STRING--04:15 OR 02:00
+1 NEW FIVE,HH,MM
+2 IF $EXTRACT(TIME,1,1)="-"
QUIT "-00:00"
+3 SET HH="00"_$PIECE(TIME,":")
SET MM="00"_$PIECE(TIME,":",2)
+4 SET HH=$EXTRACT(HH,$LENGTH(HH)-1,$LENGTH(HH))
+5 SET MM=$EXTRACT(MM,$LENGTH(MM)-1,$LENGTH(MM))
+6 SET MM=$PIECE(TIME,":",2)_"0"
+7 SET MM=$EXTRACT(MM,1,2)
+8 SET FIVE=HH_":"_MM
+9 QUIT FIVE
TWENTY4(TIME) ;CONVERT TIME TO TWENTY FOUR HOUR TIME
+1 ;
+2 ; TIME Y: 0=Mid=0,1=Mid=2400 Output: Y=time in 2400
+3 SET Y=0
+4 IF TIME="MID"!(TIME="NOON")
Begin DoDot:1
+5 SET Y=$SELECT(TIME="NOON":1200,TIME="MID":2400,1:0)
End DoDot:1
+6 IF '$TEST
Begin DoDot:1
+7 SET Y=$PIECE(TIME,":",1)_$PIECE(TIME,":",2)
SET Y=+Y
End DoDot:1
+8 IF TIME["P"
Begin DoDot:1
+9 if Y<1200
SET Y=Y+1200
End DoDot:1
+10 ;
+11 ; pad time with leading zeros so we always have 4 digits
+12 ; for cases like start times of 15 past midnight 0015
+13 ;
+14 SET Y="000"_Y
+15 SET Y=$EXTRACT(Y,$LENGTH(Y)-3,$LENGTH(Y))
+16 QUIT Y
MEALESS(HHMM,MEAL) ;Remove meal time from hours total
+1 ; (subtract a 15 minute increment from length of time
+2 ; in hh:mm format, i.e. hh:mm - mm
+3 ;
+4 NEW X,Y,DECR,OBJ,I
+5 ; get minutes
SET MM=$PIECE(HHMM,":",2)
+6 ; quit minutes or meal not quarter hours
+7 if (MM#15'=0&(+MM)!((MEAL#15)'=0&(+MEAL)))
QUIT HHMM
+8 ; get hours
+9 SET HH=$PIECE(HHMM,":")
+10 ;
+11 ; convert segment minutes and meal to a digit.
+12 ;
+13 SET X=MM
DO MEALIN
SET OBJ=X
+14 SET X=$GET(MEAL)
DO MEALIN
SET DECR=X
+15 IF OBJ=0
SET OBJ=4
+16 FOR I=1:1:DECR
Begin DoDot:1
+17 IF OBJ=4
SET HH="0"_(+HH-1)
SET HH=$EXTRACT(HH,$LENGTH(HH)-1,$LENGTH(HH))
+18 SET OBJ=$SELECT(OBJ=4:3,OBJ=3:2,OBJ=2:1,OBJ=1:4)
End DoDot:1
+19 SET MM=$SELECT(OBJ=1:15,OBJ=2:30,OBJ=3:45,1:"00")
+20 QUIT $$FIVE(HH_":"_MM)
+21 ;
MEALIN ;convert 15 minute meal to a digit
+1 IF +X#15=0
SET X=X\15
QUIT
+2 IF "^0^00^15^30^45^60^75^90^105^120^"[("^"_$GET(X)_"^")
Begin DoDot:1
+3 SET X=$SELECT(+X=0:0,X=60:4,X=30:2,X=15:1,X=45:3,1:0)
End DoDot:1
+4 IF '$TEST
Begin DoDot:1
+5 KILL X
End DoDot:1
+6 QUIT
MEALOUT ; convert meal digit to minutes
+1 SET Y=$SELECT(Y=1:15,Y=2:30,Y=3:45,Y=4:60,1:"00")
+2 QUIT
+3 ;
VALIDTT ; Set DDSERROR if not a valid type of time.
+1 ;This procedure is called from ScreenMan form PRSA ESR EDIT (file 458)
+2 ;with the validate field of the Type Of Time.
+3 ; set DDSERROR to reject user input, then ring bell and
+4 ; display a message reject explanation
+5 if X=""!($GET(PPI)'>0)!($GET(PRSIEN)'>0)!($GET(PRSD)'>0)
QUIT
+6 IF "^RG^AL^AA^DL^ML^RL^CP^SL^HX^CB^AD^WP^TR^TV^"'[(U_X_U)
Begin DoDot:1
+7 SET DDSERROR=1
+8 DO HLP^DDSUTL("Invalid type of time.")
End DoDot:1
+9 IF "^HX^"[(U_X_U)
Begin DoDot:1
+10 IF $PIECE($GET(^PRST(458,PPI,"E",PRSIEN,"D",PRSD,0)),"^",12)'>0
SET DDSERROR=1
DO HLP^DDSUTL("Holiday Excused is only allowed on a Holiday Benefit Day. See Payroll to set this day as a holiday.")
End DoDot:1
+11 IF $GET(PPI)
IF $GET(PRSD)
IF $PIECE(^PRST(458,PPI,1),U,PRSD)>$GET(DT)
Begin DoDot:1
+12 IF "^AL^AA^DL^ML^RL^CP^SL^HX^CB^AD^WP^TR^TV^"'[(U_X_U)
Begin DoDot:2
+13 SET DDSERROR=1
+14 DO HLP^DDSUTL("Invalid type of time. Only leave may be entered on future days")
End DoDot:2
End DoDot:1
+15 QUIT
VALIDLV(SSCH,SPST) ; Set DDSERROR if any posting is outside the
+1 ; tour time segements inappropriately
+2 ;
+3 ;INPUT:
+4 ; SSCH : tour segments as scheduled from node 1 of the day multiple
+5 ; SPST : tour segments as posted by ptp in T array format
+6 NEW OK,P1,P2,S1,S2,LV,I,I2,J,MSA,VALIDLV
+7 SET (LV,OK,I)=0
+8 SET VALIDLV=""
+9 ; put tour in similar format as posting
+10 DO MARRAY(.MSA,SSCH)
+11 FOR
SET I=$ORDER(SPST(I))
if I'>0!(LV&'OK)
QUIT
Begin DoDot:1
+12 SET P1=I
SET I2=$ORDER(SPST(I,0))
SET P2=$PIECE(SPST(I,I2),U)
+13 if "^AL^AA^DL^CU^ML^RL^HX^SL^CB^AD^WP^TV^TR^"'[$PIECE(SPST(I,I2),U,4)
QUIT
+14 SET LV=1
SET OK=0
+15 SET J=0
+16 FOR
SET J=$ORDER(MSA(J))
if J'>0!OK
QUIT
Begin DoDot:2
+17 SET S1=J
SET S2=$ORDER(MSA(J,0))
SET S2=$PIECE(MSA(J,S2),U)
+18 IF P1=S1!(P1>S1)&((P2=S2)!(P2<S2))
SET OK=1
End DoDot:2
End DoDot:1
+19 ;
+20 IF LV
IF ('OK)
SET VALIDLV=1
+21 QUIT VALIDLV
+22 ;
MARRAY(MARRAY,SEGS) ; BUILD MINUTE ARRAY
+1 ; INPUT : SEGS--tour of duty segments in global format
+2 ; OUTPUT: MARRAY--array by reference of tour segments in minutes
+3 ; from midnight format
+4 ; EXAMPLE:
+5 ; 2 segment tour will look like the following:
+6 ; MARRAY(945,1)=1140^03:45P^07:00P
+7 ; MARRAY(1140,6)=1305^07:00P^09:45P
+8 ; MARRAY(1320,11)=1380^10:00P^11:00P
+9 ;loop thru the 5 columns of the 7 time segments on ESR
+10 ; quit if we encounter an error
+11 ;
+12 NEW I,ANY,Z1,Z2,X,Y
+13 SET ANY=1
+14 FOR I=1:3:21
if ('ANY)
QUIT
Begin DoDot:1
+15 ;
+16 ;if absolutely nothing on the segment then we're done
+17 SET ANY=$LENGTH($PIECE(SEGS,U,I)_$PIECE(SEGS,U,I+1)_$PIECE(SEGS,U,I+2))
+18 if 'ANY
QUIT
+19 SET X=$PIECE(SEGS,U,I)_U_$PIECE(SEGS,U,I+1)
+20 DO CNV^PRSATIM
SET Z1=$PIECE(Y,U,1)
SET Z2=$PIECE(Y,U,2)
+21 DO V0^PRSATP1
+22 SET MARRAY(Z1,I)=Z2_U_$PIECE(SEGS,U,I,I+2)
End DoDot:1
+23 QUIT
PSTML(ROW) ; AUTO POST MEAL TIME
+1 ; if the time segment row that we are on in a form covers
+2 ; the tour then post a meal.
+3 ; ROW - is passed as the
+4 ; Z is in the form of NODE 5 in the 458.02 day mult
+5 ; it changes with edits on the form
+6 ; like Z=09:00A^NOON^RG^^30^NOON^08:00P^RG^^^08:00P^MID^CU^15
+7 ;
+8 NEW RNG,ST2SP,FLDNUM,BASE
+9 if $GET(PRSML)=""!($GET(PRSML)=0)
QUIT
+10 ;
+11 SET BASE=ROW-1*5
+12 ; quit if something is already in mealtime on the form
+13 if $PIECE(Z,U,BASE+5)'=""
QUIT
+14 ; compute the field number of the meal time for this row
+15 SET FLDNUM=BASE+114
+16 ; get the start TO stop segments for this row of the form
+17 ; if it's an exact match then auto post the meal
+18 SET ST2SP=$PIECE(Z,U,BASE+1,BASE+2)
+19 IF ST2SP=$PIECE($GET(PRSN1),U,1,2)
Begin DoDot:1
+20 DO PUT^DDSVAL(DIE,.DA,FLDNUM,PRSML)
+21 DO REFRESH^DDSUTL
End DoDot:1
QUIT
+22 ; get the start TO stop segments for this row of the form
+23 ; if it covers the meal and then some autopost the meal
+24 NEW DY2,TWO,SCHED,POST,SCH,P1,P2,S1,S2
+25 ; TOD is a global set up in form start up in ESRFRM^PRSPESR1
+26 SET ST2SP=$PIECE(Z,U,BASE+1,BASE+3)
+27 SET SCHED=$PIECE($GET(PRSN1),U,1,3)
+28 ; is this a two day tour? need to check before calling the
+29 ; code to set up the minutes array in MARRAY
+30 SET TWO=$PIECE($GET(^PRST(457.1,+TOD,0)),U,5)
+31 SET DY2=TWO="Y"
+32 DO MARRAY(.POST,ST2SP)
+33 DO MARRAY(.SCH,$PIECE($GET(PRSN1),U,1,3))
+34 ;get start and stop time minutes form midnight for both
+35 ; schedule and posting to determine if meal should be autoposted
+36 SET P1=$ORDER(POST(0))
+37 if P1'>0
QUIT
+38 SET P2=$PIECE(POST(P1,1),U)
+39 if P2'>0
QUIT
+40 SET S1=$ORDER(SCH(0))
+41 if S1'>0
QUIT
+42 SET S2=$PIECE(SCH(S1,1),U)
+43 if 22'>0
QUIT
+44 IF P1'>S1&(P2'<S2)
Begin DoDot:1
+45 DO PUT^DDSVAL(DIE,.DA,FLDNUM,PRSML)
+46 DO REFRESH^DDSUTL
+47 SET $PIECE(Z,U,BASE+5)=PRSML
End DoDot:1
+48 QUIT
+49 ;
OVEREAT(ROW) ; Display warning on POST ACTION ON CHANGE for the
+1 ; meal field on the form if lunch more than allotted for tour
+2 NEW MTOT,K,BASE,WORK,STR,PRSZ
+3 ; When X is null they are trying to delete and that's always ok
+4 if $GET(Z)=""!($GET(ROW)'>0)!($GET(X)="")
QUIT
+5 SET BASE=ROW-1*5
+6 ;
+7 SET WORK=$$ELAPSE^PRSPESR2(X,$PIECE(Z,U,BASE+1),$PIECE(Z,U,BASE+2))
+8 IF $EXTRACT(WORK,1,1)="-"!(WORK="00:00")!(WORK=0)
Begin DoDot:1
+9 SET DDSERROR=1
+10 SET STR="Meal time greater than or equal to time segment."
+11 IF X=0
SET STR=STR_" Type @ to remove meal time."
+12 DO HLP^DDSUTL(STR)
End DoDot:1
QUIT
+13 SET MTOT=0
+14 SET PRSZ=Z
SET $PIECE(PRSZ,U,BASE+5)=X
+15 FOR K=1:5:31
SET MTOT=MTOT+$PIECE(PRSZ,U,K+4)
+16 IF MTOT>($GET(PRSML)+$GET(PRSML2))
Begin DoDot:1
+17 SET STR="Warning: More meal time than allotted with tour."
+18 DO HLP^DDSUTL(.STR)
End DoDot:1
+19 QUIT
BURP(PRSN5) ; return ESR WORK NODE with no blank pieces
+1 ; PRSN5--esr work node $G(^PRST(458,PPI,"E",PRSIEN,"D",PRSD,5)
+2 ; if there's only a meal with a zero then skip that too.
+3 ;^^^^^NOON^08:00P^RG^^^08:00P^MID^CU^15
+4 ;
+5 NEW SN,I,TSEG
+6 SET SN=""
+7 FOR I=1:5:31
Begin DoDot:1
+8 SET TSEG=$PIECE(PRSN5,U,I,I+4)
+9 ; W !,I,": ",TSEG
+10 if TSEG="^^^^"!(TSEG="")!(TSEG="^^^^0")
QUIT
+11 SET SN=SN_TSEG_"^"
End DoDot:1
+12 QUIT SN