PSADRI ; GENERATED FROM 'PSADRI' PRINT TEMPLATE (#3786) ; 11/29/04 ; (FILE 50, MARGIN=80)
G BEGIN
N W !
T W:$X ! I '$D(DIOT(2)),DN,$D(IOSL),$S('$D(DIWF):1,$P(DIWF,"B",2):$P(DIWF,"B",2),1:1)+$Y'<IOSL,$D(^UTILITY($J,1))#2,^(1)?1U1P1E.E X ^(1)
S DISTP=DISTP+1,DILCT=DILCT+1 D:'(DISTP#100) CSTP^DIO2
Q
DT I $G(DUZ("LANG"))>1,Y W $$OUT^DIALOGU(Y,"DD") Q
I Y W $P("JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC",U,$E(Y,4,5))_" " W:Y#100 $J(Y#100\1,2)_"," W Y\10000+1700 W:Y#1 " "_$E(Y_0,9,10)_":"_$E(Y_"000",11,12) Q
W Y Q
M D @DIXX
Q
BEGIN ;
S:'$D(DN) DN=1 S DISTP=$G(DISTP),DILCT=$G(DILCT)
I $D(DXS)<9 M DXS=^DIPT(3786,"DXS")
S I(0)="^PSDRUG(",J(0)=50
D N:$X>0 Q:'DN W ?0 W "DRUG file"
D N:$X>39 Q:'DN W ?39 W "ITEM MASTER file"
D N:$X>0 Q:'DN W ?0 S X="_",DIP(1)=X S X=80,X1=DIP(1) S %=X,X="" Q:X1="" S $P(X,X1,%\$L(X1)+1)=X1,X=$E(X,1,%) K DIP K:DN Y W X
S X=$G(^PSDRUG(D0,0)) D T Q:'DN D N D N:$X>0 Q:'DN W ?0,$E($P(X,U,1),1,35)
S I(100)="^PRC(441,",J(100)=441 X DXS(1,9.2) S DIP(101)=$S($D(^PRC(441,D0,0)):^(0),1:"") S X=$P(DIP(101),U,1) S D0=I(0,0) S D0=D(0) I D0>0 D A1
G A1R
A1 ;
S I(101)=1,J(101)=441.02 F D1=0:0 Q:$O(^PRC(441,D0,1,D1))'>0 S D1=$O(^(D1)) D:$X>37 T Q:'DN D A2
G A2R
A2 ;
S X=$G(^PRC(441,D0,1,D1,0)) S DIWL=38,DIWR=77 D ^DIWP
Q
A2R ;
D 0^DIWW
D ^DIWW
S NO=D0 K DIP K:DN Y
D N:$X>39 Q:'DN W ?39 S DIP(101)=$S($D(^PRC(441,D0,0)):^(0),1:"") S X="ITEM NUMBER: "_$P(DIP(101),U,1) K DIP K:DN Y W X
D T Q:'DN D N W ?0 S DIP(1)=$S($D(^PSDRUG(I(0,0),0)):^(0),1:"") S X=$P(DIP(1),U,6) K DIP K:DN Y W X
D N:$X>29 Q:'DN W ?29 W "-NSN-"
S X=$G(^PRC(441,D0,0)) D N:$X>39 Q:'DN W ?39,$E($P(X,U,5),1,17)
D T Q:'DN D N W ?0 S DIP(1)=$S($D(^PSDRUG(I(0,0),2)):^(2),1:"") S X=$P(DIP(1),U,4) K DIP K:DN Y W X
W ?11 S NDC=X K DIP K:DN Y
D N:$X>29 Q:'DN W ?29 W "-NDC-"
D N:$X>39 Q:'DN W ?39 S VE=$O(^PRC(441,"F",NDC,+NO,"")) W $P(^PRC(441,+NO,2,+VE,0),U,5) K DIP K:DN Y
D T Q:'DN D N W ?0 S DIP(1)=$S($D(^PSDRUG(I(0,0),660)):^(660),1:"") S X="$"_$P(DIP(1),U,3)_"/"_$S('$D(^DIC(51.5,+$P(DIP(1),U,2),0)):"",1:$P(^(0),U,1)) K DIP K:DN Y W X
D N:$X>29 Q:'DN W ?29 W "-COST-"
D N:$X>39 Q:'DN W ?39 X DXS(2,9) K DIP K:DN Y
W ?50 W "Date of price: " S Y=$P(^PRC(441,+NO,2,+VE,0),U,6) X ^DD("DD") W Y K DIP K:DN Y
D T Q:'DN D N W ?0 S DIP(1)=$S($D(^PSDRUG(I(0,0),660)):^(660),1:"") S X=$P(DIP(1),U,5)_"/"_$S('$D(^DIC(51.5,+$P(DIP(1),U,2),0)):"",1:$P(^(0),U,1)) K DIP K:DN Y W X
D N:$X>29 Q:'DN W ?29 W "-PKG-"
D N:$X>39 Q:'DN W ?39 X DXS(3,9) K DIP K:DN Y
D T Q:'DN D N W ?0 S DIP(1)=$S($D(^PSDRUG(I(0,0),660)):^(660),1:"") S X="$"_$P(DIP(1),U,6)_"/"_$P(DIP(1),U,8) K DIP K:DN Y W X
D N:$X>26 Q:'DN W ?26 W "-UNIT COST-"
D N:$X>39 Q:'DN W ?39 W "$" K DIP K:DN Y
S PR=$P(^PRC(441,+NO,2,+VE,0),U,2) K DIP K:DN Y
X DXS(4,9) K DIP K:DN Y W X
W ?50 W "(Based on dispense unit)"
D T Q:'DN D N W ?0 S DIP(1)=$S($D(^PSDRUG(I(0,0),660)):^(660),1:"") S X=$P(DIP(1),U,7) K DIP K:DN Y W X
D N:$X>28 Q:'DN W ?28 W "-SOURCE-"
D N:$X>39 Q:'DN W ?39 W $P($G(^PRC(440,+$P(^PRC(441,+NO,2,+VE,0),U),0)),U) K DIP K:DN Y
D T Q:'DN D N D N:$X>0 Q:'DN W ?0 S DIP(101)=$S($D(^PRC(441,D0,0)):^(0),1:"") S X="Purchasing Agent: "_$S('$D(^VA(200,+$P(DIP(101),U,11),0)):"",1:$P(^(0),U,1)) K DIP K:DN Y W X
S I(200)="^VA(200,",J(200)=200 X DXS(5,9.2) S DIP(201)=$S($D(^VA(200,D0,0)):^(0),1:"") S X=$P(DIP(201),U,1) S D0=I(100,0) S D0=D(0) I D0>0 D B2
G B2R
B2 ;
D N:$X>39 Q:'DN W ?39 S DIP(201)=$S($D(^VA(200,D0,.13)):^(.13),1:"") S X="Phone: "_$P(DIP(201),U,2) K DIP K:DN Y W X
Q
B2R ;
K J(200),I(200) S:$D(I(100,0)) D0=I(100,0)
Q
A1R ;
K J(100),I(100) S:$D(I(0,0)) D0=I(0,0)
K Y K DIWF
Q
HEAD ;
W !,"--------------------------------------------------------------------------------",!!
PSADRI ; GENERATED FROM 'PSADRI' PRINT TEMPLATE (#3786) ; 11/29/04 ; (FILE 50, MARGIN=80)
+1 GOTO BEGIN
N WRITE !
T IF $X
WRITE !
IF '$DATA(DIOT(2))
IF DN
IF $DATA(IOSL)
IF $SELECT('$DATA(DIWF):1,$PIECE(DIWF,"B",2):$PIECE(DIWF,"B",2),1:1)+$Y'<IOSL
IF $DATA(^UTILITY($JOB,1))#2
IF ^(1)?1U1P1E.E
XECUTE ^(1)
+1 SET DISTP=DISTP+1
SET DILCT=DILCT+1
IF '(DISTP#100)
DO CSTP^DIO2
+2 QUIT
DT IF $GET(DUZ("LANG"))>1
IF Y
WRITE $$OUT^DIALOGU(Y,"DD")
QUIT
+1 IF Y
WRITE $PIECE("JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC",U,$EXTRACT(Y,4,5))_" "
IF Y#100
WRITE $JUSTIFY(Y#100\1,2)_","
WRITE Y\10000+1700
IF Y#1
WRITE " "_$EXTRACT(Y_0,9,10)_":"_$EXTRACT(Y_"000",11,12)
QUIT
+2 WRITE Y
QUIT
M DO @DIXX
+1 QUIT
BEGIN ;
+1 IF '$DATA(DN)
SET DN=1
SET DISTP=$GET(DISTP)
SET DILCT=$GET(DILCT)
+2 IF $DATA(DXS)<9
MERGE DXS=^DIPT(3786,"DXS")
+3 SET I(0)="^PSDRUG("
SET J(0)=50
+4 IF $X>0
DO N
IF 'DN
QUIT
WRITE ?0
WRITE "DRUG file"
+5 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
WRITE "ITEM MASTER file"
+6 IF $X>0
DO N
IF 'DN
QUIT
WRITE ?0
SET X="_"
SET DIP(1)=X
SET X=80
SET X1=DIP(1)
SET %=X
SET X=""
IF X1=""
QUIT
SET $PIECE(X,X1,%\$LENGTH(X1)+1)=X1
SET X=$EXTRACT(X,1,%)
KILL DIP
IF DN
KILL Y
WRITE X
+7 SET X=$GET(^PSDRUG(D0,0))
DO T
IF 'DN
QUIT
DO N
IF $X>0
DO N
IF 'DN
QUIT
WRITE ?0,$EXTRACT($PIECE(X,U,1),1,35)
+8 SET I(100)="^PRC(441,"
SET J(100)=441
XECUTE DXS(1,9.2)
SET DIP(101)=$SELECT($DATA(^PRC(441,D0,0)):^(0),1:"")
SET X=$PIECE(DIP(101),U,1)
SET D0=I(0,0)
SET D0=D(0)
IF D0>0
DO A1
+9 GOTO A1R
A1 ;
+1 SET I(101)=1
SET J(101)=441.02
FOR D1=0:0
IF $ORDER(^PRC(441,D0,1,D1))'>0
QUIT
SET D1=$ORDER(^(D1))
IF $X>37
DO T
IF 'DN
QUIT
DO A2
+2 GOTO A2R
A2 ;
+1 SET X=$GET(^PRC(441,D0,1,D1,0))
SET DIWL=38
SET DIWR=77
DO ^DIWP
+2 QUIT
A2R ;
+1 DO 0^DIWW
+2 DO ^DIWW
+3 SET NO=D0
KILL DIP
IF DN
KILL Y
+4 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
SET DIP(101)=$SELECT($DATA(^PRC(441,D0,0)):^(0),1:"")
SET X="ITEM NUMBER: "_$PIECE(DIP(101),U,1)
KILL DIP
IF DN
KILL Y
WRITE X
+5 DO T
IF 'DN
QUIT
DO N
WRITE ?0
SET DIP(1)=$SELECT($DATA(^PSDRUG(I(0,0),0)):^(0),1:"")
SET X=$PIECE(DIP(1),U,6)
KILL DIP
IF DN
KILL Y
WRITE X
+6 IF $X>29
DO N
IF 'DN
QUIT
WRITE ?29
WRITE "-NSN-"
+7 SET X=$GET(^PRC(441,D0,0))
IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39,$EXTRACT($PIECE(X,U,5),1,17)
+8 DO T
IF 'DN
QUIT
DO N
WRITE ?0
SET DIP(1)=$SELECT($DATA(^PSDRUG(I(0,0),2)):^(2),1:"")
SET X=$PIECE(DIP(1),U,4)
KILL DIP
IF DN
KILL Y
WRITE X
+9 WRITE ?11
SET NDC=X
KILL DIP
IF DN
KILL Y
+10 IF $X>29
DO N
IF 'DN
QUIT
WRITE ?29
WRITE "-NDC-"
+11 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
SET VE=$ORDER(^PRC(441,"F",NDC,+NO,""))
WRITE $PIECE(^PRC(441,+NO,2,+VE,0),U,5)
KILL DIP
IF DN
KILL Y
+12 DO T
IF 'DN
QUIT
DO N
WRITE ?0
SET DIP(1)=$SELECT($DATA(^PSDRUG(I(0,0),660)):^(660),1:"")
SET X="$"_$PIECE(DIP(1),U,3)_"/"_$SELECT('$DATA(^DIC(51.5,+$PIECE(DIP(1),U,2),0)):"",1:$PIECE(^(0),U,1))
KILL DIP
IF DN
KILL Y
WRITE X
+13 IF $X>29
DO N
IF 'DN
QUIT
WRITE ?29
WRITE "-COST-"
+14 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
XECUTE DXS(2,9)
KILL DIP
IF DN
KILL Y
+15 WRITE ?50
WRITE "Date of price: "
SET Y=$PIECE(^PRC(441,+NO,2,+VE,0),U,6)
XECUTE ^DD("DD")
WRITE Y
KILL DIP
IF DN
KILL Y
+16 DO T
IF 'DN
QUIT
DO N
WRITE ?0
SET DIP(1)=$SELECT($DATA(^PSDRUG(I(0,0),660)):^(660),1:"")
SET X=$PIECE(DIP(1),U,5)_"/"_$SELECT('$DATA(^DIC(51.5,+$PIECE(DIP(1),U,2),0)):"",1:$PIECE(^(0),U,1))
KILL DIP
IF DN
KILL Y
WRITE X
+17 IF $X>29
DO N
IF 'DN
QUIT
WRITE ?29
WRITE "-PKG-"
+18 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
XECUTE DXS(3,9)
KILL DIP
IF DN
KILL Y
+19 DO T
IF 'DN
QUIT
DO N
WRITE ?0
SET DIP(1)=$SELECT($DATA(^PSDRUG(I(0,0),660)):^(660),1:"")
SET X="$"_$PIECE(DIP(1),U,6)_"/"_$PIECE(DIP(1),U,8)
KILL DIP
IF DN
KILL Y
WRITE X
+20 IF $X>26
DO N
IF 'DN
QUIT
WRITE ?26
WRITE "-UNIT COST-"
+21 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
WRITE "$"
KILL DIP
IF DN
KILL Y
+22 SET PR=$PIECE(^PRC(441,+NO,2,+VE,0),U,2)
KILL DIP
IF DN
KILL Y
+23 XECUTE DXS(4,9)
KILL DIP
IF DN
KILL Y
WRITE X
+24 WRITE ?50
WRITE "(Based on dispense unit)"
+25 DO T
IF 'DN
QUIT
DO N
WRITE ?0
SET DIP(1)=$SELECT($DATA(^PSDRUG(I(0,0),660)):^(660),1:"")
SET X=$PIECE(DIP(1),U,7)
KILL DIP
IF DN
KILL Y
WRITE X
+26 IF $X>28
DO N
IF 'DN
QUIT
WRITE ?28
WRITE "-SOURCE-"
+27 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
WRITE $PIECE($GET(^PRC(440,+$PIECE(^PRC(441,+NO,2,+VE,0),U),0)),U)
KILL DIP
IF DN
KILL Y
+28 DO T
IF 'DN
QUIT
DO N
IF $X>0
DO N
IF 'DN
QUIT
WRITE ?0
SET DIP(101)=$SELECT($DATA(^PRC(441,D0,0)):^(0),1:"")
SET X="Purchasing Agent: "_$SELECT('$DATA(^VA(200,+$PIECE(DIP(101),U,11),0)):"",1:$PIECE(^(0),U,1))
KILL DIP
IF DN
KILL Y
WRITE X
+29 SET I(200)="^VA(200,"
SET J(200)=200
XECUTE DXS(5,9.2)
SET DIP(201)=$SELECT($DATA(^VA(200,D0,0)):^(0),1:"")
SET X=$PIECE(DIP(201),U,1)
SET D0=I(100,0)
SET D0=D(0)
IF D0>0
DO B2
+30 GOTO B2R
B2 ;
+1 IF $X>39
DO N
IF 'DN
QUIT
WRITE ?39
SET DIP(201)=$SELECT($DATA(^VA(200,D0,.13)):^(.13),1:"")
SET X="Phone: "_$PIECE(DIP(201),U,2)
KILL DIP
IF DN
KILL Y
WRITE X
+2 QUIT
B2R ;
+1 KILL J(200),I(200)
IF $DATA(I(100,0))
SET D0=I(100,0)
+2 QUIT
A1R ;
+1 KILL J(100),I(100)
IF $DATA(I(0,0))
SET D0=I(0,0)
+2 KILL Y
KILL DIWF
+3 QUIT
HEAD ;
+1 WRITE !,"--------------------------------------------------------------------------------",!!