PSDUP3 ;BHM/DAV,JPW-IRL Program/Data Download Vault Inv. Insp. ; 5 Oct 94
;;3.0; CONTROLLED SUBSTANCES ;**3**;13 Feb 97
VAULT ;vault upload
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
ASKD ;ask disp location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) LOOP
W ! K DIC,DA S DIC=58.8,DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)",DIC("A")="Select Dispensing Site to Inventory: ",DIC("B")=$P(PSDSITE,U,4)
D ^DIC K DIC
I Y<0 W $C(7),!!,"No action taken!",!! G Q
S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
LOOP ;loop and set ^tmp for trakker
I $D(PSDTRAKU) Q
K ^TMP("PSDUP3",$J)
W !!,"Compiling inventory data...",!
F PSD=0:0 S PSD=$O(^PSD(58.8,+PSDS,1,PSD)) Q:'PSD I $D(^PSD(58.8,+PSDS,1,PSD,0)) S QTY=+$P($G(^(0)),"^",4) D
.S PSDN=$S($P($G(^PSDRUG(+PSD,0)),"^")]"":$P($G(^(0)),"^"),1:"UNKNOWN")
.S ^TMP("PSDUP3",$J,PSD)=PSDN_"^"_QTY
START ;begin
D ^%ZIS G Q:POP S PSDIO=IO,PSDIO(0)=IOST(0) U IO X:$D(^%ZIS(2,IOST(0),10)) ^(10)
W !,"/$",!,".$1",!,"$$",!,"I",!
K X,X1
1 S X1=$S('$D(X1):$O(^PSD(58.88,1,1,0)),1:$O(^PSD(58.88,1,1,X1))) G 2:X1'>0 S X=$P(^PSD(58.88,1,1,X1,0),"::")
F Y=$L(X):-1:0 Q:$E(X,Y)'=" " S X=$E(X,1,(Y-1))
W X,! G 1
;
2 W !,"ER",!,"//",! X:$D(^%ZIS(2,IOST(0),11)) ^(11) H 3 W !,"Awaiting TRAKKER signal" F X=1:1 R XX:DTIME Q:XX="*" G NOSIGN:XX["^"!('$T)
U PSDIO X:$D(^%ZIS(2,PSDIO(0),10)) ^(10)
I XX="*" W "*"_+PSDS,!
K DATA
DATA S DATA="" F S DATA=$O(^TMP("PSDUP3",$J,DATA)) G QQ:DATA="" S DATA(1)=^TMP("PSDUP3",$J,DATA) W DATA,!,$P(DATA(1),U),!,$P(DATA(1),U,2),!
QQ W !,"END" X:$D(^%ZIS(2,PSDIO(0),11)) ^(11)
W !,"You can now disconnect the TRAKKER.",!! H 2
D ^%ZISC
G Q
UPLOAD ;upload data to DHCP
K CNT,DA,DATA,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,PSDS,PSDSN,X,X1,Y
S PSDTRAKU=1 D VAULT K PSDTRAKU
I '$G(PSDS) W !,"No vault identified." G Q
S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,1:0)
I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"upload this data to the trakker.",!!,?12,"The PSJ RPHARM security key is required.",! G Q
W !!,"Use the Send Data to DHCP option on the TRAKKER at this time.",!
K CNT,X,^TMP("PSDWN3",$J) S PSDCON=$C(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)
UP1 R !,X:DTIME S:X'="" CNT=$G(CNT)+1 G FIL:X["++++" I $G(CNT)=1 S:X'="" ^TMP("PSDWN3",$J,CNT,0)=$TR(X,PSDCON) G UP1
S:X'="" ^TMP("PSDWN3",$J,CNT,0)=$TR(X,PSDCON) G UP1
G UP1
FIL I $D(^TMP("PSDWN3",$J)) G ^PSDFIL3
Q K CNT,DA,DATA,DIC,DTOUT,DUOUT,OK,POP,PSD,PSDCON,PSDIO,PSDN,PSDS,PSDSN,PROG,QTY,X,X1,XX,Y
K ^TMP("PSDUP3",$J)
Q
NOSIGN W $C(7),$C(7),!!,"No signal received from the TRAKKER",! D ^%ZISC G Q
PSDUP3 ;BHM/DAV,JPW-IRL Program/Data Download Vault Inv. Insp. ; 5 Oct 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;**3**;13 Feb 97
VAULT ;vault upload
+1 IF '$DATA(PSDSITE)
DO ^PSDSET
IF '$DATA(PSDSITE)
QUIT
ASKD ;ask disp location
+1 SET PSDS=$PIECE(PSDSITE,U,3)
SET PSDSN=$PIECE(PSDSITE,U,4)
+2 IF $PIECE(PSDSITE,U,5)
GOTO LOOP
+3 WRITE !
KILL DIC,DA
SET DIC=58.8
SET DIC(0)="QEAZ"
SET DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
SET DIC("A")="Select Dispensing Site to Inventory: "
SET DIC("B")=$PIECE(PSDSITE,U,4)
+4 DO ^DIC
KILL DIC
+5 IF Y<0
WRITE $CHAR(7),!!,"No action taken!",!!
GOTO Q
+6 SET PSDS=+Y
SET PSDSN=$PIECE(Y,"^",2)
SET $PIECE(PSDSITE,U,3)=+Y
SET $PIECE(PSDSITE,U,4)=PSDSN
LOOP ;loop and set ^tmp for trakker
+1 IF $DATA(PSDTRAKU)
QUIT
+2 KILL ^TMP("PSDUP3",$JOB)
+3 WRITE !!,"Compiling inventory data...",!
+4 FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.8,+PSDS,1,PSD))
IF 'PSD
QUIT
IF $DATA(^PSD(58.8,+PSDS,1,PSD,0))
SET QTY=+$PIECE($GET(^(0)),"^",4)
Begin DoDot:1
+5 SET PSDN=$SELECT($PIECE($GET(^PSDRUG(+PSD,0)),"^")]"":$PIECE($GET(^(0)),"^"),1:"UNKNOWN")
+6 SET ^TMP("PSDUP3",$JOB,PSD)=PSDN_"^"_QTY
End DoDot:1
START ;begin
+1 DO ^%ZIS
IF POP
GOTO Q
SET PSDIO=IO
SET PSDIO(0)=IOST(0)
USE IO
IF $DATA(^%ZIS(2,IOST(0),10))
XECUTE ^(10)
+2 WRITE !,"/$",!,".$1",!,"$$",!,"I",!
+3 KILL X,X1
1 SET X1=$SELECT('$DATA(X1):$ORDER(^PSD(58.88,1,1,0)),1:$ORDER(^PSD(58.88,1,1,X1)))
IF X1'>0
GOTO 2
SET X=$PIECE(^PSD(58.88,1,1,X1,0),"::")
+1 FOR Y=$LENGTH(X):-1:0
IF $EXTRACT(X,Y)'=" "
QUIT
SET X=$EXTRACT(X,1,(Y-1))
+2 WRITE X,!
GOTO 1
+3 ;
2 WRITE !,"ER",!,"//",!
IF $DATA(^%ZIS(2,IOST(0),11))
XECUTE ^(11)
HANG 3
WRITE !,"Awaiting TRAKKER signal"
FOR X=1:1
READ XX:DTIME
IF XX="*"
QUIT
IF XX["^"!('$TEST)
GOTO NOSIGN
+1 USE PSDIO
IF $DATA(^%ZIS(2,PSDIO(0),10))
XECUTE ^(10)
+2 IF XX="*"
WRITE "*"_+PSDS,!
+3 KILL DATA
DATA SET DATA=""
FOR
SET DATA=$ORDER(^TMP("PSDUP3",$JOB,DATA))
IF DATA=""
GOTO QQ
SET DATA(1)=^TMP("PSDUP3",$JOB,DATA)
WRITE DATA,!,$PIECE(DATA(1),U),!,$PIECE(DATA(1),U,2),!
QQ WRITE !,"END"
IF $DATA(^%ZIS(2,PSDIO(0),11))
XECUTE ^(11)
+1 WRITE !,"You can now disconnect the TRAKKER.",!!
HANG 2
+2 DO ^%ZISC
+3 GOTO Q
UPLOAD ;upload data to DHCP
+1 KILL CNT,DA,DATA,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,PSDS,PSDSN,X,X1,Y
+2 SET PSDTRAKU=1
DO VAULT
KILL PSDTRAKU
+3 IF '$GET(PSDS)
WRITE !,"No vault identified."
GOTO Q
+4 SET OK=$SELECT($DATA(^XUSEC("PSJ RPHARM",DUZ)):1,1:0)
+5 IF 'OK
WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"upload this data to the trakker.",!!,?12,"The PSJ RPHARM security key is required.",!
GOTO Q
+6 WRITE !!,"Use the Send Data to DHCP option on the TRAKKER at this time.",!
+7 KILL CNT,X,^TMP("PSDWN3",$JOB)
SET PSDCON=$CHAR(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)
UP1 READ !,X:DTIME
IF X'=""
SET CNT=$GET(CNT)+1
IF X["++++"
GOTO FIL
IF $GET(CNT)=1
IF X'=""
SET ^TMP("PSDWN3",$JOB,CNT,0)=$TRANSLATE(X,PSDCON)
GOTO UP1
+1 IF X'=""
SET ^TMP("PSDWN3",$JOB,CNT,0)=$TRANSLATE(X,PSDCON)
GOTO UP1
+2 GOTO UP1
FIL IF $DATA(^TMP("PSDWN3",$JOB))
GOTO ^PSDFIL3
Q KILL CNT,DA,DATA,DIC,DTOUT,DUOUT,OK,POP,PSD,PSDCON,PSDIO,PSDN,PSDS,PSDSN,PROG,QTY,X,X1,XX,Y
+1 KILL ^TMP("PSDUP3",$JOB)
+2 QUIT
NOSIGN WRITE $CHAR(7),$CHAR(7),!!,"No signal received from the TRAKKER",!
DO ^%ZISC
GOTO Q