PSDLBL1 ;BIR/JPW-CS Label Print for Vault Drugs ; 29 Aug 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"print CS dispensing labels.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",! K OK Q
ASKD ;ask disp location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) CHKD
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)"
S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=PSDSN
D ^DIC K DIC G:Y<0 END
S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
CHKD I '$O(^PSD(58.8,PSDS,1,0)) W !!,"There are no CS stocked drugs for your dispensing vault.",!! G END
DRUG ;ask drug
W !!,?5,"You may select a single drug, several drugs,",!,?5,"or enter ^ALL to select all drugs.",!!
W ! K DA,DIC
F S DIC("W")="W:$P(^PSDRUG(Y,0),""^"",9) "" N/F"" I $P(^PSD(58.8,PSDS,1,Y,0),""^"",14)]"""",$P(^(0),""^"",14)'>DT W $C(7),"" *** INACTIVE ***""",DA(1)=+PSDS,DIC(0)="QEAM",DIC="^PSD(58.8,"_PSDS_",1," D ^DIC K DIC Q:Y<0 D
.S PSDRG(+Y)=""
I '$D(PSDRG)&(X'="^ALL") G END
I X="^ALL" S ALL=1
DEV ;ask device and queue info
W $C(7),!!,?3,"WARNING: The printing of these labels requires the use of a sheet fed",!,?12,"laser printer setup to create Controlled Substances",!,?12,"barcodes.",!
W !,?12,"*** Check printer for LABEL paper before printing! ***",!
W !!,"This report is designed for a 3 column label format.",!,"You may queue this report to print at a later time.",!!
S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",10),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")=PSDEV D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END
I $D(IO("Q")) K IO("Q"),ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDLBL1",ZTDESC="Print Vault Labels for CS PHARM" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;entry for compile and print labels
K ^TMP("PSDLBL1",$J),PSDPRT
F JJ=0,1 S @("PSDBAR"_JJ)="" I $D(^%ZIS(2,^%ZIS(1,IOS,"SUBTYPE"),"BAR"_JJ)) S @("PSDBAR"_JJ)=^("BAR"_JJ)
I PSDBAR1]"",PSDBAR0]"" S PSDPRT=1
I $D(ALL) F PSD=0:0 S PSD=$O(^PSD(58.8,+PSDS,1,PSD)) Q:'PSD S:$S('$P($G(^PSD(58.8,+PSDS,1,PSD,0)),U,14):1,$P($G(^(0)),U,4):1,$P($G(^(0)),U,14)>DT:1,1:0) PSDRG(PSD)=""
F PSD=0:0 S PSD=$O(PSDRG(PSD)) Q:'PSD I $D(^PSD(58.8,+PSDS,1,PSD,0)) D
.S PSDRN=$S($P($G(^PSDRUG(+PSD,0)),"^")]"":$P($G(^(0)),"^"),1:"UNKNOWN")
.S ^TMP("PSDLBL1",$J,PSDRN)=PSD
PRINT ;print labels
S (PSDOUT,PSDCNT)=0,PSDX2=1
S PSD="" F S PSD=$O(^TMP("PSDLBL1",$J,PSD)) Q:PSD=""!(PSDOUT) S PSDCNT=PSDCNT+1,TEMP(PSDCNT)=$E(PSD,1,28),TEST(PSDCNT)=$P(^TMP("PSDLBL1",$J,PSD),"^") D:PSDCNT=3 PRINT1
I PSDCNT,PSDCNT<3 D PRINT1
DONE I $E(IOST)'="C" W @IOF
I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR,DIRUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu" D ^DIR K DIR
END ;kill variables and exit
K %ZIS,ALL,C,DA,DIC,DIR,DIROUT,DIRUT,DRUG,DTOUT,DUOUT,JJ,JLP1,OK,POP,PSD,PSDBAR0,PSDBAR1,PSDCNT,PSDEV,PSDOUT,PSDRG,PSDPRT,PSDRN,PSDS,PSDSN,PSDX1,PSDX2,TEMP,TEST,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDLBL1",$J)
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
SAVE ;save queued variables
S:$D(ALL) ZTSAVE("ALL")=""
S:$D(PSDRG) ZTSAVE("PSDRG(")=""
S (ZTSAVE("PSDS"),ZTSAVE("PSDSN"))=""
Q
PRINT1 ;prints labels
W ! F PSDX1=0:1:PSDCNT-1 W ?PSDX1*33+1,$E(TEMP(PSDX1+1),1,30)
I $D(PSDPRT) W !! F PSDX1=1:1:PSDCNT W @PSDBAR1,TEST(PSDX1),@PSDBAR0
W ! F PSDX1=0:1:PSDCNT-1 W ?PSDX1*32+3,TEST(PSDX1+1)
W !!
S PSDCNT=0,PSDX2=PSDX2+1 S:PSDX2=11 PSDX2=1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDLBL1 3767 printed Dec 13, 2024@01:46:30 Page 2
PSDLBL1 ;BIR/JPW-CS Label Print for Vault Drugs ; 29 Aug 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
+2 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
QUIT
+3 SET OK=$SELECT($DATA(^XUSEC("PSJ RPHARM",DUZ)):1,$DATA(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
+4 IF 'OK
WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"print CS dispensing labels.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",!
KILL OK
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 CHKD
+3 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)"
+4 SET DIC("A")="Select Primary Dispensing Site: "
SET DIC("B")=PSDSN
+5 DO ^DIC
KILL DIC
if Y<0
GOTO END
+6 SET PSDS=+Y
SET PSDSN=$PIECE(Y,"^",2)
SET $PIECE(PSDSITE,U,3)=+Y
SET $PIECE(PSDSITE,U,4)=PSDSN
CHKD IF '$ORDER(^PSD(58.8,PSDS,1,0))
WRITE !!,"There are no CS stocked drugs for your dispensing vault.",!!
GOTO END
DRUG ;ask drug
+1 WRITE !!,?5,"You may select a single drug, several drugs,",!,?5,"or enter ^ALL to select all drugs.",!!
+2 WRITE !
KILL DA,DIC
+3 FOR
SET DIC("W")="W:$P(^PSDRUG(Y,0),""^"",9) "" N/F"" I $P(^PSD(58.8,PSDS,1,Y,0),""^"",14)]"""",$P(^(0),""^"",14)'>DT W $C(7),"" *** INACTIVE ***"""
SET DA(1)=+PSDS
SET DIC(0)="QEAM"
SET DIC="^PSD(58.8,"_PSDS_",1,"
DO ^DIC
KILL DIC
if Y<0
QUIT
Begin DoDot:1
+4 SET PSDRG(+Y)=""
End DoDot:1
+5 IF '$DATA(PSDRG)&(X'="^ALL")
GOTO END
+6 IF X="^ALL"
SET ALL=1
DEV ;ask device and queue info
+1 WRITE $CHAR(7),!!,?3,"WARNING: The printing of these labels requires the use of a sheet fed",!,?12,"laser printer setup to create Controlled Substances",!,?12,"barcodes.",!
+2 WRITE !,?12,"*** Check printer for LABEL paper before printing! ***",!
+3 WRITE !!,"This report is designed for a 3 column label format.",!,"You may queue this report to print at a later time.",!!
+4 SET Y=$PIECE($GET(^PSD(58.8,+PSDS,2)),"^",10)
SET C=$PIECE(^DD(58.8,24,0),"^",2)
DO Y^DIQ
SET PSDEV=Y
+5 KILL %ZIS,IOP,IO("Q"),POP
SET %ZIS="QM"
SET %ZIS("B")=PSDEV
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO END
+6 IF $DATA(IO("Q"))
KILL IO("Q"),ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDLBL1"
SET ZTDESC="Print Vault Labels for CS PHARM"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+7 USE IO
START ;entry for compile and print labels
+1 KILL ^TMP("PSDLBL1",$JOB),PSDPRT
+2 FOR JJ=0,1
SET @("PSDBAR"_JJ)=""
IF $DATA(^%ZIS(2,^%ZIS(1,IOS,"SUBTYPE"),"BAR"_JJ))
SET @("PSDBAR"_JJ)=^("BAR"_JJ)
+3 IF PSDBAR1]""
IF PSDBAR0]""
SET PSDPRT=1
+4 IF $DATA(ALL)
FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.8,+PSDS,1,PSD))
if 'PSD
QUIT
if $SELECT('$PIECE($GET(^PSD(58.8,+PSDS,1,PSD,0)),U,14)
SET PSDRG(PSD)=""
+5 FOR PSD=0:0
SET PSD=$ORDER(PSDRG(PSD))
if 'PSD
QUIT
IF $DATA(^PSD(58.8,+PSDS,1,PSD,0))
Begin DoDot:1
+6 SET PSDRN=$SELECT($PIECE($GET(^PSDRUG(+PSD,0)),"^")]"":$PIECE($GET(^(0)),"^"),1:"UNKNOWN")
+7 SET ^TMP("PSDLBL1",$JOB,PSDRN)=PSD
End DoDot:1
PRINT ;print labels
+1 SET (PSDOUT,PSDCNT)=0
SET PSDX2=1
+2 SET PSD=""
FOR
SET PSD=$ORDER(^TMP("PSDLBL1",$JOB,PSD))
if PSD=""!(PSDOUT)
QUIT
SET PSDCNT=PSDCNT+1
SET TEMP(PSDCNT)=$EXTRACT(PSD,1,28)
SET TEST(PSDCNT)=$PIECE(^TMP("PSDLBL1",$JOB,PSD),"^")
if PSDCNT=3
DO PRINT1
+3 IF PSDCNT
IF PSDCNT<3
DO PRINT1
DONE IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST,1,2)="C-"
IF 'PSDOUT
WRITE !
KILL DIR,DIRUT
SET DIR(0)="EA"
SET DIR("A")="END OF REPORT! Press <RET> to return to the menu"
DO ^DIR
KILL DIR
END ;kill variables and exit
+1 KILL %ZIS,ALL,C,DA,DIC,DIR,DIROUT,DIRUT,DRUG,DTOUT,DUOUT,JJ,JLP1,OK,POP,PSD,PSDBAR0,PSDBAR1,PSDCNT,PSDEV,PSDOUT,PSDRG,PSDPRT,PSDRN,PSDS,PSDSN,PSDX1,PSDX2,TEMP,TEST,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
+2 KILL ^TMP("PSDLBL1",$JOB)
+3 DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
+4 QUIT
SAVE ;save queued variables
+1 if $DATA(ALL)
SET ZTSAVE("ALL")=""
+2 if $DATA(PSDRG)
SET ZTSAVE("PSDRG(")=""
+3 SET (ZTSAVE("PSDS"),ZTSAVE("PSDSN"))=""
+4 QUIT
PRINT1 ;prints labels
+1 WRITE !
FOR PSDX1=0:1:PSDCNT-1
WRITE ?PSDX1*33+1,$EXTRACT(TEMP(PSDX1+1),1,30)
+2 IF $DATA(PSDPRT)
WRITE !!
FOR PSDX1=1:1:PSDCNT
WRITE @PSDBAR1,TEST(PSDX1),@PSDBAR0
+3 WRITE !
FOR PSDX1=0:1:PSDCNT-1
WRITE ?PSDX1*32+3,TEST(PSDX1+1)
+4 WRITE !!
+5 SET PSDCNT=0
SET PSDX2=PSDX2+1
if PSDX2=11
SET PSDX2=1
+6 QUIT