PSARIN ;BIR/LTL-Loadable Inventory Items Report ;7/23/97
;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**15**; 10/24/97
;This routine reports the inventory/DA items.
;
;References to $$INVNAME^PRCPUX1 are covered by IA #259
;References to $$UNITCODE^PRCPUX1 are covered by IA #259
;References to ^PSDRUG( are covered by IA #2095
;References to ^PSDRUG("AB" are covered by IA #2095
;References to ^PRC( are covered by IA #214
;References to ^PRCP( are covered by IA #214
;
SETUP N D0,D1,DA,DIE,DIC,DIR,DIRUT,DLAYGO,DR,DTOUT,DUOUT,PSADRUG,PSAINV,PSAOUT,X,Y
;LOOK UP LOCATION
LOOK D ^PSADA I '$G(PSALOC) S PSAOUT=1 G QUIT
NOINV I '$O(^PSD(58.8,+PSALOC,4,0)) W !,$G(PSALOCN)_" is not linked to an Inventory Point.",! D G:$G(PSAOUT) QUIT
.S DIR(0)="Y",DIR("A")="Would you like to attempt a link now",DIR("B")="Yes" D ^DIR K DIR S:Y'=1 PSAOUT=1 Q:Y'=1 D I $D(Y)!('$G(PSAINV)) S PSAOUT=1 Q
INV ..S DIE=58.8,DA=PSALOC,DR="[PSAGIP]" D ^DIE K DIE
DEV K IO("Q") N %ZIS,IOP,POP S %ZIS="Q" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" S PSAOUT=1 G QUIT
I $D(IO("Q")) N ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSARIN",ZTDESC="Inventory items to load into DA Location",ZTSAVE("PSA*")="" D ^%ZTLOAD,HOME^%ZIS S PSAOUT=1 G QUIT
START N %DT,PSALN,PSAIT,PSAL,PSAD,PSAPG,PSARPDT,X,Y S (PSAPG,PSAOUT)=0,Y=DT D DD^%DT S PSARPDT=Y,PSAIT=0
S PSAD="W !!,PSAIT,?10,$E($$DESCR^PRCPUX1(PSAINV,PSAIT),1,33),?45,$E($P(^PSDRUG($O(^PSDRUG(""AB"",PSAIT,0)),0),U),1,34)"
S PSAINV=$O(^PSD(58.8,+PSALOC,4,0))
I $O(^PSD(58.8,+PSALOC,4,+PSAINV)) D S:Y<1 PSAOUT=1 G QUIT
.S DIC="^PSD(58.8,+PSALOC,4,",DIC(0)="AEMQ",DA(1)=PSALOC D ^DIC K DIC
.S PSAINV=+Y
D HEADER
LOOP F S PSAIT=$O(^PRCP(445,PSAINV,1,PSAIT)) Q:'PSAIT D:$Y+4>IOSL HEADER Q:PSAOUT I '$G(^PRC(441,PSAIT,3)),$O(^PSDRUG("AB",PSAIT,"")) S PSADRUG=$O(^PSDRUG("AB",PSAIT,"")) D:'$D(^PSD(58.8,PSALOC,1,PSADRUG,0))
.S PSADRUG(1)=PSADRUG
.I $S('$D(^PSDRUG(PSADRUG,"I")):1,+^("I")>DT:1,1:0) X PSAD W !!,"Inventory balance: " S PSAIT(1)=$G(^PRCP(445,+PSAINV,1,+PSAIT,0)) D
..W $P(PSAIT(1),U,7)," ",$$UNITCODE^PRCPUX1($P(PSAIT(1),U,5))," times dispensing unit conv factor = ",$P(PSAIT(1),U,7)*$S($P(PSAIT(1),U,29):$P(PSAIT(1),U,29),1:1)," ",$P(PSAIT(1),U,28)
QUIT I $E(IOST)'="C" W @IOF
I $E(IOST,1,2)="C-",'$G(PSAOUT) W !! S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu." D ^DIR
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@" K IO("Q")
K PSAIT Q
I $$S^%ZTLOAD W !!,"Task #",$G(ZTSK),", ",$G(ZTDESC)," was stopped by ",$P($G(^VA(200,+$G(DUZ),0)),U),"." S PSAOUT=1 Q
S PSAINV(1)=$E($P(^PSD(58.8,PSALOC,0),U),1,10)
S:$E(PSAINV(1),10)="(" PSAINV(1)=$E(PSAINV(1),1,9)
W:$Y @IOF S $P(PSALN,"-",81)="",PSAPG=PSAPG+1 W !,$E($$INVNAME^PRCPUX1(PSAINV),1,24)_" items to load into "_PSAINV(1),?56,PSARPDT,?70,"PAGE: "_PSAPG,!,PSALN,!,"ITEM",?10,"DESCRIPTION",?50,"DRUG FILE LINK"
Q
PSARIN ;BIR/LTL-Loadable Inventory Items Report ;7/23/97
+1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**15**; 10/24/97
+2 ;This routine reports the inventory/DA items.
+3 ;
+4 ;References to $$INVNAME^PRCPUX1 are covered by IA #259
+5 ;References to $$UNITCODE^PRCPUX1 are covered by IA #259
+6 ;References to ^PSDRUG( are covered by IA #2095
+7 ;References to ^PSDRUG("AB" are covered by IA #2095
+8 ;References to ^PRC( are covered by IA #214
+9 ;References to ^PRCP( are covered by IA #214
+10 ;
SETUP NEW D0,D1,DA,DIE,DIC,DIR,DIRUT,DLAYGO,DR,DTOUT,DUOUT,PSADRUG,PSAINV,PSAOUT,X,Y
+1 ;LOOK UP LOCATION
LOOK DO ^PSADA
IF '$GET(PSALOC)
SET PSAOUT=1
GOTO QUIT
NOINV IF '$ORDER(^PSD(58.8,+PSALOC,4,0))
WRITE !,$GET(PSALOCN)_" is not linked to an Inventory Point.",!
Begin DoDot:1
+1 SET DIR(0)="Y"
SET DIR("A")="Would you like to attempt a link now"
SET DIR("B")="Yes"
DO ^DIR
KILL DIR
IF Y'=1
SET PSAOUT=1
IF Y'=1
QUIT
Begin DoDot:2
INV SET DIE=58.8
SET DA=PSALOC
SET DR="[PSAGIP]"
DO ^DIE
KILL DIE
End DoDot:2
IF $DATA(Y)!('$GET(PSAINV))
SET PSAOUT=1
QUIT
End DoDot:1
IF $GET(PSAOUT)
GOTO QUIT
DEV KILL IO("Q")
NEW %ZIS,IOP,POP
SET %ZIS="Q"
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
SET PSAOUT=1
GOTO QUIT
+1 IF $DATA(IO("Q"))
NEW ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSARIN"
SET ZTDESC="Inventory items to load into DA Location"
SET ZTSAVE("PSA*")=""
DO ^%ZTLOAD
DO HOME^%ZIS
SET PSAOUT=1
GOTO QUIT
START NEW %DT,PSALN,PSAIT,PSAL,PSAD,PSAPG,PSARPDT,X,Y
SET (PSAPG,PSAOUT)=0
SET Y=DT
DO DD^%DT
SET PSARPDT=Y
SET PSAIT=0
+1 SET PSAD="W !!,PSAIT,?10,$E($$DESCR^PRCPUX1(PSAINV,PSAIT),1,33),?45,$E($P(^PSDRUG($O(^PSDRUG(""AB"",PSAIT,0)),0),U),1,34)"
+2 SET PSAINV=$ORDER(^PSD(58.8,+PSALOC,4,0))
+3 IF $ORDER(^PSD(58.8,+PSALOC,4,+PSAINV))
Begin DoDot:1
+4 SET DIC="^PSD(58.8,+PSALOC,4,"
SET DIC(0)="AEMQ"
SET DA(1)=PSALOC
DO ^DIC
KILL DIC
+5 SET PSAINV=+Y
End DoDot:1
IF Y<1
SET PSAOUT=1
GOTO QUIT
+6 DO HEADER
LOOP FOR
SET PSAIT=$ORDER(^PRCP(445,PSAINV,1,PSAIT))
IF 'PSAIT
QUIT
IF $Y+4>IOSL
DO HEADER
IF PSAOUT
QUIT
IF '$GET(^PRC(441,PSAIT,3))
IF $ORDER(^PSDRUG("AB",PSAIT,""))
SET PSADRUG=$ORDER(^PSDRUG("AB",PSAIT,""))
IF '$DATA(^PSD(58.8,PSALOC,1,PSADRUG,0))
Begin DoDot:1
+1 SET PSADRUG(1)=PSADRUG
+2 IF $SELECT('$DATA(^PSDRUG(PSADRUG,"I")):1,+^("I")>DT:1,1:0)
XECUTE PSAD
WRITE !!,"Inventory balance: "
SET PSAIT(1)=$GET(^PRCP(445,+PSAINV,1,+PSAIT,0))
Begin DoDot:2
+3 WRITE $PIECE(PSAIT(1),U,7)," ",$$UNITCODE^PRCPUX1($PIECE(PSAIT(1),U,5))," times dispensing unit conv factor = ",$PIECE(PSAIT(1),U,7)*$SELECT($PIECE(PSAIT(1),U,29):$PIECE(PSAIT(1),U,29),1:1)," ",$PIECE(PSAIT(1),U,28)
End DoDot:2
End DoDot:1
QUIT IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST,1,2)="C-"
IF '$GET(PSAOUT)
WRITE !!
SET DIR(0)="EA"
SET DIR("A")="END OF REPORT! Press <RET> to return to the menu."
DO ^DIR
+2 DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
KILL IO("Q")
+3 KILL PSAIT
QUIT
IF PSAPG
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET PSAOUT=1
QUIT
+1 IF $$S^%ZTLOAD
WRITE !!,"Task #",$GET(ZTSK),", ",$GET(ZTDESC)," was stopped by ",$PIECE($GET(^VA(200,+$GET(DUZ),0)),U),"."
SET PSAOUT=1
QUIT
+2 SET PSAINV(1)=$EXTRACT($PIECE(^PSD(58.8,PSALOC,0),U),1,10)
+3 IF $EXTRACT(PSAINV(1),10)="("
SET PSAINV(1)=$EXTRACT(PSAINV(1),1,9)
+4 IF $Y
WRITE @IOF
SET $PIECE(PSALN,"-",81)=""
SET PSAPG=PSAPG+1
WRITE !,$EXTRACT($$INVNAME^PRCPUX1(PSAINV),1,24)_" items to load into "_PSAINV(1),?56,PSARPDT,?70,"PAGE: "_PSAPG,!,PSALN,!,"ITEM",?10,"DESCRIPTION",?50,"DRUG FILE LINK"
+5 QUIT