PSDPMFG ;BIR/JPW-Print Mfg/Lot #/Exp. Date for Stock Drugs ; 6 July 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
W !!,"=> This report lists Manufacturer, Lot #, Expiration Date, and Narcotic ",!," Information for CS Stock Drugs.",!
W !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
I '$O(^PSD(58.8,0)) W !!,"You MUST create NAOUs before running this report!" Q
ASKN ;ask NAOU(s)
D NOW^%DTC S PSDT=X K DA,DIC S CNT=0,DIC("B")=$P(PSDSITE,U,4)
F S DIC=58.8,DIC("A")="Select NAOU: ",DIC(0)="QEA",DIC("S")="I $S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>PSDT:1,1:0),$P(^(0),""^"",3)=+PSDSITE,$P(^(0),""^"",2)'=""P""" D ^DIC K DIC Q:Y<0 S NAOU(+Y)="",CNT=CNT+1
I '$D(NAOU)&(X'="^ALL") G END
I X="^ALL" F PSD=0:0 S PSD=$O(^PSD(58.8,PSD)) Q:'PSD I $S('$D(^PSD(58.8,PSD,"I")):1,'^("I"):1,+^("I")>PSDT:1,1:0),$P($G(^(0)),"^",2)'="P",$P($G(^(0)),"^",3)=+PSDSITE S NAOU(+PSD)="",CNT=CNT+1
K DA,DIR,DIRUT S DIR(0)="SO^D:DRUG/NAOU;N:NAOU/DRUG",DIR("A",1)="You may print by either of these sorting methods."
S DIR("?",1)="Enter 'D' to print the report sorted by DRUG then NAOU",DIR("?")="Enter 'N' to print the report sorted by NAOU then DRUG."
S DIR("A")="Select SORT ORDER for Report" D ^DIR K DIR G:$D(DIRUT) END S ANS=Y
DEV ;ask device and queueing information
W !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")="" 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^PSDPMFG",ZTDESC="Compile Mfg Data for CS PHARM Stock Drugs" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;compile mfg/lot #/exp. date/narcotic breakdown unit/pkg data
K ^TMP("PSDPMFG",$J)
F PSD=0:0 S PSD=$O(NAOU(PSD)) G:('PSD)&($D(ZTQUEUED)) PRTQUE G:'PSD PRINT^PSDPMFG1 I $D(^PSD(58.8,PSD,0)) F DRUG=0:0 S DRUG=$O(^PSD(58.8,PSD,1,DRUG)) Q:'DRUG D
.S NAOUN=$S($P($G(^PSD(58.8,PSD,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSD)
.Q:'$D(^PSD(58.8,PSD,1,DRUG,0)) S NODE=^PSD(58.8,PSD,1,DRUG,0) I +$P(NODE,"^",14) D NOW^%DTC I $P(^PSD(58.8,PSD,1,DRUG,0),"^",14)'>X Q
.Q:'$D(^PSDRUG(DRUG,0)) I $D(^PSDRUG(DRUG,0)) S DRUGN=$S($P(^PSDRUG(DRUG,0),"^")]"":$P(^(0),"^"),1:"ZZ/"_DRUG)
.S MFG=$S($P(NODE,"^",10)]"":$P(NODE,"^",10),1:"____________________")
.S LOT=$S($P(NODE,"^",11)]"":$P(NODE,"^",11),1:"__________"),EXP=$S($P(NODE,"^",12)]"":$P(NODE,"^",12),1:"__________")
.S BKU=$S($P(NODE,"^",8)]"":$P(NODE,"^",8),1:"__________"),PKG=$S($P(NODE,"^",9)]"":$P(NODE,"^",9),1:"__________") I +EXP S Y=EXP X ^DD("DD") S EXP=Y
.I (CNT=1)!(ANS="N") S ^TMP("PSDPMFG",$J,NAOUN,DRUGN)=MFG_"^"_LOT_"^"_EXP_"^"_BKU_"^"_PKG
.I ANS="D",CNT'=1 S ^TMP("PSDPMFG",$J,DRUGN,NAOUN)=MFG_"^"_LOT_"^"_EXP_"^"_BKU_"^"_PKG
Q
PRTQUE ;queues print after data is compiled
K ZTSAVE,ZTIO S ZTIO=PSDIO,ZTRTN="PRINT^PSDPMFG1",ZTDESC="Print Mfg Data for CS PHARM Stock Drugs",ZTDTH=$H,ZTSAVE("^TMP(""PSDPMFG"",$J,")="",ZTSAVE("ANS")="",ZTSAVE("CNT")=""
D ^%ZTLOAD K ^TMP("PSDPMFG",$J),ZTSK
END ;
K %,%H,%I,%ZIS,ANS,BKU,CNT,DA,DIC,DIR,DIROUT,DIRUT,DIK,DRUG,DRUGN,DTOUT,DUOUT,EXP,IO("Q"),LOT,MFG,NAOU,NAOUN,NODE,PKG,POP,PSD,PSDIO,PSDT
K X,Y,ZTDESC,ZTDTH,ZTIO,ZTSAVE,ZTRTN,^TMP("PSDPMFG",$J) D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@"
Q
SAVE ;save variables for queueing
S ZTSAVE("PSDIO")="",ZTSAVE("PSDT")="",ZTSAVE("ANS")="",ZTSAVE("PSDSITE")=""
S ZTSAVE("CNT")="",ZTSAVE("NAOU(")="",ZTSAVE("PSD")=""
Q
PSDPMFG ;BIR/JPW-Print Mfg/Lot #/Exp. Date for Stock Drugs ; 6 July 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
+2 IF '$DATA(PSDSITE)
DO ^PSDSET
IF '$DATA(PSDSITE)
QUIT
+3 WRITE !!,"=> This report lists Manufacturer, Lot #, Expiration Date, and Narcotic ",!," Information for CS Stock Drugs.",!
+4 WRITE !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
+5 IF '$ORDER(^PSD(58.8,0))
WRITE !!,"You MUST create NAOUs before running this report!"
QUIT
ASKN ;ask NAOU(s)
+1 DO NOW^%DTC
SET PSDT=X
KILL DA,DIC
SET CNT=0
SET DIC("B")=$PIECE(PSDSITE,U,4)
+2 FOR
SET DIC=58.8
SET DIC("A")="Select NAOU: "
SET DIC(0)="QEA"
SET DIC("S")="I $S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>PSDT:1,1:0),$P(^(0),""^"",3)=+PSDSITE,$P(^(0),""^"",2)'=""P"""
DO ^DIC
KILL DIC
IF Y<0
QUIT
SET NAOU(+Y)=""
SET CNT=CNT+1
+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 $SELECT('$DATA(^PSD(58.8,PSD,"I")):1,'^("I"):1,+^("I")>PSDT:1,1:0)
IF $PIECE($GET(^(0)),"^",2)'="P"
IF $PIECE($GET(^(0)),"^",3)=+PSDSITE
SET NAOU(+PSD)=""
SET CNT=CNT+1
+5 KILL DA,DIR,DIRUT
SET DIR(0)="SO^D:DRUG/NAOU;N:NAOU/DRUG"
SET DIR("A",1)="You may print by either of these sorting methods."
+6 SET DIR("?",1)="Enter 'D' to print the report sorted by DRUG then NAOU"
SET DIR("?")="Enter 'N' to print the report sorted by NAOU then DRUG."
+7 SET DIR("A")="Select SORT ORDER for Report"
DO ^DIR
KILL DIR
IF $DATA(DIRUT)
GOTO END
SET ANS=Y
DEV ;ask device and queueing information
+1 WRITE !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
+2 KILL %ZIS,IOP,IO("Q"),POP
SET %ZIS="QM"
SET %ZIS("B")=""
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO END
+3 IF $DATA(IO("Q"))
KILL IO("Q")
SET PSDIO=ION
SET ZTIO=""
KILL ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDPMFG"
SET ZTDESC="Compile Mfg Data for CS PHARM Stock Drugs"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+4 USE IO
START ;compile mfg/lot #/exp. date/narcotic breakdown unit/pkg data
+1 KILL ^TMP("PSDPMFG",$JOB)
+2 FOR PSD=0:0
SET PSD=$ORDER(NAOU(PSD))
IF ('PSD)&($DATA(ZTQUEUED))
GOTO PRTQUE
IF 'PSD
GOTO PRINT^PSDPMFG1
IF $DATA(^PSD(58.8,PSD,0))
FOR DRUG=0:0
SET DRUG=$ORDER(^PSD(58.8,PSD,1,DRUG))
IF 'DRUG
QUIT
Begin DoDot:1
+3 SET NAOUN=$SELECT($PIECE($GET(^PSD(58.8,PSD,0)),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_PSD)
+4 IF '$DATA(^PSD(58.8,PSD,1,DRUG,0))
QUIT
SET NODE=^PSD(58.8,PSD,1,DRUG,0)
IF +$PIECE(NODE,"^",14)
DO NOW^%DTC
IF $PIECE(^PSD(58.8,PSD,1,DRUG,0),"^",14)'>X
QUIT
+5 IF '$DATA(^PSDRUG(DRUG,0))
QUIT
IF $DATA(^PSDRUG(DRUG,0))
SET DRUGN=$SELECT($PIECE(^PSDRUG(DRUG,0),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_DRUG)
+6 SET MFG=$SELECT($PIECE(NODE,"^",10)]"":$PIECE(NODE,"^",10),1:"____________________")
+7 SET LOT=$SELECT($PIECE(NODE,"^",11)]"":$PIECE(NODE,"^",11),1:"__________")
SET EXP=$SELECT($PIECE(NODE,"^",12)]"":$PIECE(NODE,"^",12),1:"__________")
+8 SET BKU=$SELECT($PIECE(NODE,"^",8)]"":$PIECE(NODE,"^",8),1:"__________")
SET PKG=$SELECT($PIECE(NODE,"^",9)]"":$PIECE(NODE,"^",9),1:"__________")
IF +EXP
SET Y=EXP
XECUTE ^DD("DD")
SET EXP=Y
+9 IF (CNT=1)!(ANS="N")
SET ^TMP("PSDPMFG",$JOB,NAOUN,DRUGN)=MFG_"^"_LOT_"^"_EXP_"^"_BKU_"^"_PKG
+10 IF ANS="D"
IF CNT'=1
SET ^TMP("PSDPMFG",$JOB,DRUGN,NAOUN)=MFG_"^"_LOT_"^"_EXP_"^"_BKU_"^"_PKG
End DoDot:1
+11 QUIT
PRTQUE ;queues print after data is compiled
+1 KILL ZTSAVE,ZTIO
SET ZTIO=PSDIO
SET ZTRTN="PRINT^PSDPMFG1"
SET ZTDESC="Print Mfg Data for CS PHARM Stock Drugs"
SET ZTDTH=$HOROLOG
SET ZTSAVE("^TMP(""PSDPMFG"",$J,")=""
SET ZTSAVE("ANS")=""
SET ZTSAVE("CNT")=""
+2 DO ^%ZTLOAD
KILL ^TMP("PSDPMFG",$JOB),ZTSK
END ;
+1 KILL %,%H,%I,%ZIS,ANS,BKU,CNT,DA,DIC,DIR,DIROUT,DIRUT,DIK,DRUG,DRUGN,DTOUT,DUOUT,EXP,IO("Q"),LOT,MFG,NAOU,NAOUN,NODE,PKG,POP,PSD,PSDIO,PSDT
+2 KILL X,Y,ZTDESC,ZTDTH,ZTIO,ZTSAVE,ZTRTN,^TMP("PSDPMFG",$JOB)
DO ^%ZISC
+3 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+4 QUIT
SAVE ;save variables for queueing
+1 SET ZTSAVE("PSDIO")=""
SET ZTSAVE("PSDT")=""
SET ZTSAVE("ANS")=""
SET ZTSAVE("PSDSITE")=""
+2 SET ZTSAVE("CNT")=""
SET ZTSAVE("NAOU(")=""
SET ZTSAVE("PSD")=""
+3 QUIT