PSDRDR ;BIR/BJW-Narc Disp/Rec Report (reprint VA FORM 10-2321) ; 12 Feb 98
;;3.0; CONTROLLED SUBSTANCES ;**8**;13 Feb 97
;**Y2K compliance**,"P" added to date input string
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
ASKD ;ask dispensing location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) SUM
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
SUM ;if ret-to-stock or turn in for dest
K DA,DIR,DIRUT W ! S DIR(0)="Y",DIR("A")="Is this a Return to Stock or Turn in for Destruction Reprint",DIR("B")="NO"
S DIR("?",1)="Answer 'YES' to select a Return to Stock or Turn in for Destruction form,",DIR("?")="answer 'NO' to print a dispensing VA FORM 10-2321."
D ^DIR K DIR G:$D(DIRUT) END S SUM=Y G:SUM TYPE^PSDRPT
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
ASKN ;ask naou or green sheet number
K DA,DIR,DIRUT S DIR(0)="SO^N:NAOU;G:Green Sheet #",DIR("A")="Select Method"
S DIR("?",1)="Enter 'N' to select one, several, or ^ALL NAOUs,",DIR("?")="enter 'G' to select a Green Sheet #, or '^' to quit"
D ^DIR K DIR G:$D(DIRUT) END S SEL=Y
I SEL="G" W ! K DA,DIC S DIC("A")="Select Green Sheet #: ",DIC=58.81,D="D",DIC(0)="QEAS",DIC("S")="I $P(^(0),""^"",3)=+PSDS" D IX^DIC G:Y<0 END S PSDA=+Y G DEV
NAOU ;sel naou
W !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
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 S NAOU(+Y)=""
I '$D(NAOU)&(X'="^ALL") G END
I X="^ALL" F PSD=0:0 S PSD=$O(^PSD(58.8,PSD)) Q:'PSD I $P($G(^PSD(58.8,PSD,0)),"^",2)="N",$P($G(^(0)),"^",4)=+PSDS S NAOU(PSD)=""
DATE ;asks date range if naou is selected
W !!,"Please enter the DATE and TIME period you wish to reprint data for this report",!
W ! K %DT S %DT="AEPRXT",%DT("A")="Start with Date/Time: " D ^%DT I Y<0 S PSDOUT=1 G END
S PSDSD=Y D D^DIQ S PSDATE=Y,%DT("A")="End with Date/Time: " D ^%DT I Y<0 S PSDOUT=1 G END
I Y<PSDSD W !!,"The ending date of the range must be later than the starting date." G DATE
S PSDED=Y D D^DIQ S PSDATE=PSDATE_"^"_Y,PSDSD=PSDSD-.0001,PSDED=PSDED+.0001
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"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDRDR1",ZTDESC="Reprint Narcotic Disp Report" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO G START^PSDRDR1
END K %,%I,%H,%ZIS,C,COMM,COPY,D,DA,DIC,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DRUG,DRUGN,DTOUT,DUOUT,EXP,EXPD,FLAG,LN,LOOP,LOT,MFG,NAOU,NAOUN,NODE,NUM,OK,ORD,ORDN
K PG,PHARM,PHARMN,PSD,PSDA,PSDATE,PSDCPY,PSDDT,PSDED,PSDEV,PSDN,PSDNA,PSDOUT,PSDS,PSDSD,PSDSN,PSDST,QTY,REC,RECN,REQD,REQDT,RPDT,SEL,SUM,TEXT,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDRDR",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
SAVE S (ZTSAVE("PSDATE"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDSN"),ZTSAVE("PSDS"),ZTSAVE("PSDCPY"))=""
S:$D(NAOU) ZTSAVE("NAOU(")="" S:$D(PSDA) ZTSAVE("PSDA")=""
Q
PSDRDR ;BIR/BJW-Narc Disp/Rec Report (reprint VA FORM 10-2321) ; 12 Feb 98
+1 ;;3.0; CONTROLLED SUBSTANCES ;**8**;13 Feb 97
+2 ;**Y2K compliance**,"P" added to date input string
+3 IF '$DATA(PSDSITE)
DO ^PSDSET
IF '$DATA(PSDSITE)
QUIT
+4 SET OK=$SELECT($DATA(^XUSEC("PSJ RPHARM",DUZ)):1,$DATA(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
+5 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
ASKD ;ask dispensing location
+1 SET PSDS=$PIECE(PSDSITE,U,3)
SET PSDSN=$PIECE(PSDSITE,U,4)
+2 IF $PIECE(PSDSITE,U,5)
GOTO SUM
+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
SUM ;if ret-to-stock or turn in for dest
+1 KILL DA,DIR,DIRUT
WRITE !
SET DIR(0)="Y"
SET DIR("A")="Is this a Return to Stock or Turn in for Destruction Reprint"
SET DIR("B")="NO"
+2 SET DIR("?",1)="Answer 'YES' to select a Return to Stock or Turn in for Destruction form,"
SET DIR("?")="answer 'NO' to print a dispensing VA FORM 10-2321."
+3 DO ^DIR
KILL DIR
IF $DATA(DIRUT)
GOTO END
SET SUM=Y
IF SUM
GOTO TYPE^PSDRPT
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
ASKN ;ask naou or green sheet number
+1 KILL DA,DIR,DIRUT
SET DIR(0)="SO^N:NAOU;G:Green Sheet #"
SET DIR("A")="Select Method"
+2 SET DIR("?",1)="Enter 'N' to select one, several, or ^ALL NAOUs,"
SET DIR("?")="enter 'G' to select a Green Sheet #, or '^' to quit"
+3 DO ^DIR
KILL DIR
IF $DATA(DIRUT)
GOTO END
SET SEL=Y
+4 IF SEL="G"
WRITE !
KILL DA,DIC
SET DIC("A")="Select Green Sheet #: "
SET DIC=58.81
SET D="D"
SET DIC(0)="QEAS"
SET DIC("S")="I $P(^(0),""^"",3)=+PSDS"
DO IX^DIC
IF Y<0
GOTO END
SET PSDA=+Y
GOTO DEV
NAOU ;sel naou
+1 WRITE !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
+2 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
SET NAOU(+Y)=""
+3 IF '$DATA(NAOU)&(X'="^ALL")
GOTO END
+4 IF X="^ALL"
FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.8,PSD))
IF 'PSD
QUIT
IF $PIECE($GET(^PSD(58.8,PSD,0)),"^",2)="N"
IF $PIECE($GET(^(0)),"^",4)=+PSDS
SET NAOU(PSD)=""
DATE ;asks date range if naou is selected
+1 WRITE !!,"Please enter the DATE and TIME period you wish to reprint data for this report",!
+2 WRITE !
KILL %DT
SET %DT="AEPRXT"
SET %DT("A")="Start with Date/Time: "
DO ^%DT
IF Y<0
SET PSDOUT=1
GOTO END
+3 SET PSDSD=Y
DO D^DIQ
SET PSDATE=Y
SET %DT("A")="End with Date/Time: "
DO ^%DT
IF Y<0
SET PSDOUT=1
GOTO END
+4 IF Y<PSDSD
WRITE !!,"The ending date of the range must be later than the starting date."
GOTO DATE
+5 SET PSDED=Y
DO D^DIQ
SET PSDATE=PSDATE_"^"_Y
SET PSDSD=PSDSD-.0001
SET PSDED=PSDED+.0001
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"),ZTIO,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDRDR1"
SET ZTDESC="Reprint Narcotic Disp Report"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+5 USE IO
GOTO START^PSDRDR1
END KILL %,%I,%H,%ZIS,C,COMM,COPY,D,DA,DIC,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DRUG,DRUGN,DTOUT,DUOUT,EXP,EXPD,FLAG,LN,LOOP,LOT,MFG,NAOU,NAOUN,NODE,NUM,OK,ORD,ORDN
+1 KILL PG,PHARM,PHARMN,PSD,PSDA,PSDATE,PSDCPY,PSDDT,PSDED,PSDEV,PSDN,PSDNA,PSDOUT,PSDS,PSDSD,PSDSN,PSDST,QTY,REC,RECN,REQD,REQDT,RPDT,SEL,SUM,TEXT,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+2 KILL ^TMP("PSDRDR",$JOB)
DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 QUIT
SAVE SET (ZTSAVE("PSDATE"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDSN"),ZTSAVE("PSDS"),ZTSAVE("PSDCPY"))=""
+1 IF $DATA(NAOU)
SET ZTSAVE("NAOU(")=""
IF $DATA(PSDA)
SET ZTSAVE("PSDA")=""
+2 QUIT