VADPT32 ;ALB/MRL/MJK - PATIENT VARIABLES [IN5], CONT.; 12 DEC 1988
;;5.3;Registration;**1004**;Aug 13, 1993
;Inpatient variables [Version 5.0 and above]
;IHS/OIT/LJF 11/10/2005 PATCH 1004 included for sites where it has been overwritten
;
BLD ; build array of mvt in reverse order up one before E mvt
K ^UTILITY("VADPTZ",$J,DFN) S (VANN,VAQ,VAZ,VACC)=0
I "^4^5^"[("^"_$P(VAMV0,"^",2)_"^") D LODGER G BLDQ
F I=0:0 S VAZ=$O(^DGPM("APMV",DFN,VAX("CA"),VAZ)),VAZ(1)=0 Q:VAQ!(VAZ'>0) F I1=0:0 S VAZ(1)=$O(^DGPM("APMV",DFN,VAX("CA"),VAZ,VAZ(1))) Q:VAQ!(VAZ(1)'>0) S VACC=VACC+1 D BA
BLDQ K VACC,VAQ,VAZ Q
;
BA ;Build Movement Array
I VANN,VACC=(VANN+2) S VAQ=1 Q
S:VAZ(1)=+E VANN=VACC S X=$S($D(^DGPM(+VAZ(1),0)):^(0),1:""),^UTILITY("VADPTZ",$J,DFN,VACC)=VAZ(1)_"||"_X Q
;
LODGER ;
S VANN=1,X=^DGPM(E,0)
I $P(X,"^",2)=5 S ^UTILITY("VADPTZ",$J,DFN,1)=E_"||"_X S:$D(^DGPM(+$P(X,"^",14),0)) ^UTILITY("VADPTZ",$J,DFN,2)=+$P(X,"^",14)_"||"_^(0)
I $P(X,"^",2)=4 S:$D(^DGPM(+$P(X,"^",17),0)) ^UTILITY("VADPTZ",$J,DFN,1)=+$P(X,"^",17)_"||"_^(0),VANN=2 S ^UTILITY("VADPTZ",$J,DFN,VANN)=E_"||"_X
Q
VADPT32 ;ALB/MRL/MJK - PATIENT VARIABLES [IN5], CONT.; 12 DEC 1988
+1 ;;5.3;Registration;**1004**;Aug 13, 1993
+2 ;Inpatient variables [Version 5.0 and above]
+3 ;IHS/OIT/LJF 11/10/2005 PATCH 1004 included for sites where it has been overwritten
+4 ;
BLD ; build array of mvt in reverse order up one before E mvt
+1 KILL ^UTILITY("VADPTZ",$JOB,DFN)
SET (VANN,VAQ,VAZ,VACC)=0
+2 IF "^4^5^"[("^"_$PIECE(VAMV0,"^",2)_"^")
DO LODGER
GOTO BLDQ
+3 FOR I=0:0
SET VAZ=$ORDER(^DGPM("APMV",DFN,VAX("CA"),VAZ))
SET VAZ(1)=0
IF VAQ!(VAZ'>0)
QUIT
FOR I1=0:0
SET VAZ(1)=$ORDER(^DGPM("APMV",DFN,VAX("CA"),VAZ,VAZ(1)))
IF VAQ!(VAZ(1)'>0)
QUIT
SET VACC=VACC+1
DO BA
BLDQ KILL VACC,VAQ,VAZ
QUIT
+1 ;
BA ;Build Movement Array
+1 IF VANN
IF VACC=(VANN+2)
SET VAQ=1
QUIT
+2 IF VAZ(1)=+E
SET VANN=VACC
SET X=$SELECT($DATA(^DGPM(+VAZ(1),0)):^(0),1:"")
SET ^UTILITY("VADPTZ",$JOB,DFN,VACC)=VAZ(1)_"||"_X
QUIT
+3 ;
LODGER ;
+1 SET VANN=1
SET X=^DGPM(E,0)
+2 IF $PIECE(X,"^",2)=5
SET ^UTILITY("VADPTZ",$JOB,DFN,1)=E_"||"_X
IF $DATA(^DGPM(+$PIECE(X,"^",14),0))
SET ^UTILITY("VADPTZ",$JOB,DFN,2)=+$PIECE(X,"^",14)_"||"_^(0)
+3 IF $PIECE(X,"^",2)=4
IF $DATA(^DGPM(+$PIECE(X,"^",17),0))
SET ^UTILITY("VADPTZ",$JOB,DFN,1)=+$PIECE(X,"^",17)_"||"_^(0)
SET VANN=2
SET ^UTILITY("VADPTZ",$JOB,DFN,VANN)=E_"||"_X
+4 QUIT