PSDPDR ;BIR/BJW-Narc Disp/Rec Report (in lieu of VA FORM 10-2321) ; 09 FEB 95
;;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,"process/dispense narcotic supplies.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",! K OK Q
COPY ;ask vault, nursing or both
K DA,DIR,DIRUT S DIR(0)="SO^V:VAULT COPY ONLY;N:NURSING COPY ONLY;B:BOTH VAULT AND NURSING COPY"
S DIR("A")="Select Disp/Receiving Report(s) to Print"
S DIR("?",1)="Answer 'V' to print only the vault copy of this report,",DIR("?",2)="answer 'N' to print only the nursing copy or",DIR("?")="answer 'B' to print both the vault and nursing copies."
D ^DIR K DIR
I $D(DIRUT) W !,"No report will be printed.",! G END
S PSDCPY=Y
ASKD ;ask dispensing location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) ASKN
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")=$P(PSDSITE,U,4)
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
ASKN ;ask naou or group
W !!,?5,"Select one of the following:",!!,?10,"N",?20,"NAOU (One, Some, or ^ALL)",!,?10,"G",?20,"Group of NAOUs",!
K DA,DIR,DIRUT S DIR(0)="SOA^N:NAOU;G:Group of NAOUs",DIR("A")="Select Method: "
S DIR("?",1)="Enter 'N' to select one, some or ^ALL NAOU(s),",DIR("?")="enter 'G' to select a group of NAOUs, or '^' to quit"
D ^DIR K DIR G:$D(DIRUT) END S SEL=Y D NOW^%DTC S PSDT=X,PSDPT=+$E(%,1,12) K DA,DIC S CNT=0
I SEL="G" D GROUP G:'$D(PSDG) END G DEV
F S DIC=58.8,DIC("A")="Select NAOU: ",DIC(0)="QEA",DIC("S")="I $P(^(0),""^"",2)=""N"",$P(^(0),""^"",4)=+PSDS" D ^DIC K DIC Q:Y<0 D
.S NAOU(+Y)="",CNT=CNT+1
I '$D(NAOU)&(X'="^ALL") G END
S:X="^ALL" ALL=1
DEV ;ask device and queue info
W !,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),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") S PSDIO=ION,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDPDR1",ZTDESC="Compile Narcotic Disp Report" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO G START^PSDPDR1
END K %,%H,%I,%ZIS,ALL,C,CNT,COPY,COMM,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT,EXP,EXPD,FLAG,LOT,MFG,NAOU,NODE,NUM
K OK,ORD,ORDN,POP,PSD,PSDCPY,PSDA,PSDDT,PSDEV,PSDG,PSDIO,PSDN,PSDNA,PSDPT,PSDR,PSDRN,PSDS,PSDSN,PSDT,PSDSN,PSDST,QTY,REQD,REQDT,SEL,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDRPT",$J) D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@"
Q
GROUP ;select group of naous
K DA,DIC F S DIC=58.2,DIC("A")="Select NAOU INVENTORY GROUP NAME: ",DIC(0)="QEA",DIC("S")="I $S($D(^PSI(58.2,""CS"",+Y)):1,1:0)" D ^DIC K DIC Q:Y<0 S PSDG(+Y)=""
Q
SAVE S (ZTSAVE("PSDIO"),ZTSAVE("PSDT"),ZTSAVE("CNT"),ZTSAVE("PSDS"),ZTSAVE("PSDPT"),ZTSAVE("PSDCPY"))="" S:$D(PSDG) ZTSAVE("PSDG(")="" S:$D(NAOU) ZTSAVE("NAOU(")="" S:$D(ALL) ZTSAVE("ALL")=""
Q
PSDPDR ;BIR/BJW-Narc Disp/Rec Report (in lieu of VA FORM 10-2321) ; 09 FEB 95
+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,"process/dispense narcotic supplies.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",!
KILL OK
QUIT
COPY ;ask vault, nursing or both
+1 KILL DA,DIR,DIRUT
SET DIR(0)="SO^V:VAULT COPY ONLY;N:NURSING COPY ONLY;B:BOTH VAULT AND NURSING COPY"
+2 SET DIR("A")="Select Disp/Receiving Report(s) to Print"
+3 SET DIR("?",1)="Answer 'V' to print only the vault copy of this report,"
SET DIR("?",2)="answer 'N' to print only the nursing copy or"
SET DIR("?")="answer 'B' to print both the vault and nursing copies."
+4 DO ^DIR
KILL DIR
+5 IF $DATA(DIRUT)
WRITE !,"No report will be printed.",!
GOTO END
+6 SET PSDCPY=Y
ASKD ;ask dispensing location
+1 SET PSDS=$PIECE(PSDSITE,U,3)
SET PSDSN=$PIECE(PSDSITE,U,4)
+2 IF $PIECE(PSDSITE,U,5)
GOTO ASKN
+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")=$PIECE(PSDSITE,U,4)
+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
ASKN ;ask naou or group
+1 WRITE !!,?5,"Select one of the following:",!!,?10,"N",?20,"NAOU (One, Some, or ^ALL)",!,?10,"G",?20,"Group of NAOUs",!
+2 KILL DA,DIR,DIRUT
SET DIR(0)="SOA^N:NAOU;G:Group of NAOUs"
SET DIR("A")="Select Method: "
+3 SET DIR("?",1)="Enter 'N' to select one, some or ^ALL NAOU(s),"
SET DIR("?")="enter 'G' to select a group of NAOUs, or '^' to quit"
+4 DO ^DIR
KILL DIR
IF $DATA(DIRUT)
GOTO END
SET SEL=Y
DO NOW^%DTC
SET PSDT=X
SET PSDPT=+$EXTRACT(%,1,12)
KILL DA,DIC
SET CNT=0
+5 IF SEL="G"
DO GROUP
IF '$DATA(PSDG)
GOTO END
GOTO DEV
+6 FOR
SET DIC=58.8
SET DIC("A")="Select NAOU: "
SET DIC(0)="QEA"
SET DIC("S")="I $P(^(0),""^"",2)=""N"",$P(^(0),""^"",4)=+PSDS"
DO ^DIC
KILL DIC
IF Y<0
QUIT
Begin DoDot:1
+7 SET NAOU(+Y)=""
SET CNT=CNT+1
End DoDot:1
+8 IF '$DATA(NAOU)&(X'="^ALL")
GOTO END
+9 IF X="^ALL"
SET ALL=1
DEV ;ask device and queue info
+1 WRITE !,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
+2 SET Y=$PIECE($GET(^PSD(58.8,+PSDS,2)),"^",9)
SET C=$PIECE(^DD(58.8,24,0),"^",2)
DO Y^DIQ
SET PSDEV=Y
+3 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
+4 IF $DATA(IO("Q"))
KILL IO("Q")
SET PSDIO=ION
SET ZTIO=""
KILL ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDPDR1"
SET ZTDESC="Compile Narcotic Disp Report"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+5 USE IO
GOTO START^PSDPDR1
END KILL %,%H,%I,%ZIS,ALL,C,CNT,COPY,COMM,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT,EXP,EXPD,FLAG,LOT,MFG,NAOU,NODE,NUM
+1 KILL OK,ORD,ORDN,POP,PSD,PSDCPY,PSDA,PSDDT,PSDEV,PSDG,PSDIO,PSDN,PSDNA,PSDPT,PSDR,PSDRN,PSDS,PSDSN,PSDT,PSDSN,PSDST,QTY,REQD,REQDT,SEL,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+2 KILL ^TMP("PSDRPT",$JOB)
DO ^%ZISC
+3 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+4 QUIT
GROUP ;select group of naous
+1 KILL DA,DIC
FOR
SET DIC=58.2
SET DIC("A")="Select NAOU INVENTORY GROUP NAME: "
SET DIC(0)="QEA"
SET DIC("S")="I $S($D(^PSI(58.2,""CS"",+Y)):1,1:0)"
DO ^DIC
KILL DIC
IF Y<0
QUIT
SET PSDG(+Y)=""
+2 QUIT
SAVE SET (ZTSAVE("PSDIO"),ZTSAVE("PSDT"),ZTSAVE("CNT"),ZTSAVE("PSDS"),ZTSAVE("PSDPT"),ZTSAVE("PSDCPY"))=""
IF $DATA(PSDG)
SET ZTSAVE("PSDG(")=""
IF $DATA(NAOU)
SET ZTSAVE("NAOU(")=""
IF $DATA(ALL)
SET ZTSAVE("ALL")=""
+1 QUIT