DGPMGLP1 ;ALB/LM - G&L PRINT ROUTINE; 8 NOV 90
 ;;5.3;Registration;;Aug 13, 1993
 ;
A I TT=6!(TT=9999)!(TT=8888),'SNM Q
 D TTHD,TT
 ;
Q Q
 ;
TTHD ;  Transaction Type
 S X1=132-$L(TTNAME)\2
 S TTNAME=$E(RA,1,X1-3)_"   "_TTNAME_"   "_$E(LA,1,X1-3)
TTHD1 D:$Y>$S($D(IOSL):(IOSL-11),1:55) FOOT^DGPMGLP,DIVHD^DGPMGLP
 W !?RM-($L(TTNAME))\2,TTNAME ; RM=Right Margin
 F L=1:1:(RM-($L(TTNAME))\2) W " "
 Q
 ;
TT S FM=0 ;  Facility Movement
 F I1=0:0 S FM=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM)) Q:'FM  S C=0,FMNAME=$S($D(^DG(405.1,+FM,0)):$P(^(0),"^"),1:"UNKNOWN MOVEMENT TYPE")_": "_$S($D(^UTILITY("DGF",$J,DGDIV,DGSRV,TT,FM)):$J(^(FM),4),1:"") D FMHD,FM
 Q
 ;
FMHD ;  Facility Movement
 D:$Y>$S($D(IOSL):(IOSL-9),1:57) FOOT^DGPMGLP,DIVHD^DGPMGLP,TTHD1
 W !?RM-($L(FMNAME))\2,FMNAME
 W:UL="-" ! W:UL="_" $C(13)
 F L=1:1:(RM-($L(FMNAME))\2) W " "
 F L=1:1:($L(FMNAME)) W UL
 Q
 ;
FM S PTNAME=0,PT=0
 S CT=0,CPZ=CP
 F I2=0:0 S PTNAME=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PTNAME)),DFN=0 Q:PTNAME=""  F I3=0:0 S DFN=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PTNAME,DFN)) Q:'DFN  S CT=CT+1
 S PO=1,CC=1
 D:CPZ=2 TWO D:CPZ=3 THREE
 Q
 ;
TWO Q:CPZ'=2
 S SC=$S(CT#CPZ>0:(CT\CPZ+2),1:CT\CPZ+1)
 ;
 F J2=0:0 S PT=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PT)),NZ=0 Q:PT=""  F J3=0:0 S NZ=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PT,NZ)) Q:'NZ  S PO=$S(CC=1:1,CC=SC:2,1:PO+2) S CC=CC+1 S PTDATA(PO)=^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PT,NZ)
 ;
PRINT2 F PO=0:0 S PO=$O(PTDATA(PO)) Q:PO=""  D:$Y>$S($D(IOSL):(IOSL-7),1:59) CONT D PRINT2A
 ;
TWOQ K SC,J2,PT,NZ,J3,PTDATA,CC,PO Q
 ;
CONT D FOOT^DGPMGLP,DIVHD^DGPMGLP,SRVHD^DGPMGLP
 I TTNAME'["Cont." S TTNAME=$P(TTNAME,":")_" Cont.   "_$E(LA,1,X1-3)
 D TTHD1
 I FMNAME'["Cont." S FMNAME=$P(FMNAME,":")_" Cont."
 D FMHD
 Q
 ;
PRINT2A I PO#CPZ>0!($L($P(PTDATA(PO),"^"))'<66) W !,$P(PTDATA(PO),"^")
 I PO#CPZ=0!(PO=2)&($L($P(PTDATA(PO),"^"))<66) W ?68,$P(PTDATA(PO),"^") I $Y=$S($D(IOSL):(IOSL-7),1:59) W !
 Q
 ;
THREE Q:CPZ'=3
 I CT#CPZ=0 S SC=CT+CPZ S TC=SC+CPZ
 I CT#CPZ=1 S SC=CT\CPZ+2 S TC=SC+CT\CPZ
 I CT#CPZ=2 S SC=CT\CPZ+(CT#CPZ) S TC=SC+(CT\CPZ)+1
 ;
 F J2=0:0 S PT=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PT)),NZ=0 Q:PT=""  F J3=0:0 S NZ=$O(^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PT,NZ)) Q:'NZ  S PTDATA(PO)=^UTILITY("DGG",$J,DGDIV,DGSRV,TT,FM,PT,NZ) S CC=CC+1 S PO=$S(CC=SC:2,CC=TC:3,1:PO+3)
 ;
PRINT3 F PO=0:0 S PO=$O(PTDATA(PO)) Q:PO=""  W:PO#CPZ=1!($P(PTDATA(PO),"^",2)) ! W:PO#CPZ=2&('$P(PTDATA(PO),"^",2)) ?44 W:PO#CPZ=0&('$P(PTDATA(PO),"^",2)) ?88 W $P(PTDATA(PO),"^")
THREEQQ K SC,TC,J2,PT,NZ,J3,PTDATA,CC,PO Q
 ;
VAR ; CPZ=Column Placement
 ; CT=Count of patients
 ; SC=Second Column starting point
 ; TC=Third Column starting point
 ; PO=Print Order
