PSDPAT ;B'ham ISC/BJW - Prt Data from TRAKKER (Patient/Drug) ; 11 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 RNURSE",DUZ)):1,$D(^XUSEC("PSD NURSE",DUZ)):1,1:0)
;I 'OK W $C(7),!!,"Contact your Nursing ADP Coordinator for access to display the Dispensing Report.",!! K OK Q
SUM ;ask detail or summary
K DA,DIR,DIRUT S DIR(0)="SO^D:DETAIL LISTING ONLY;S:SUMMARY LISTING ONLY"
S DIR("A")="Select Dispensing Report(s) to Print"
S DIR("?",1)="Answer 'D' to print only the transaction detail for this report,",DIR("?",2)="answer 'S' to print only the summary totals or <RET> to quit."
D ^DIR K DIR G:$D(DIRUT) END S SUM=Y
ASKN ;select NAOU for report
K DA,DIC
S DIC=58.8,DIC(0)="QEA",DIC("A")="Select NAOU: ",DIC("B")=$G(NAOUN)
S DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)"
D ^DIC K DIC G:Y<0 END S NAOU=+Y,NAOUN=$P(Y,"^",2)
I '+$P($G(^PSD(58.8,NAOU,2)),"^",5) W !!,"This NAOU does not maintain a perpetual inventory balance to list",!,"Dispensing data.",!! K NAOU,NAOUN G ASKN
CHKD I '$O(^PSD(58.8,NAOU,1,0)) W !!,"There are no CS stocked drugs for the NAOU you selected.",!! G ASKN
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,NAOU,1,Y,0),""^"",14)]"""",$P(^(0),""^"",14)'>DT W $C(7),"" *** INACTIVE ***""",DA(1)=+NAOU,DIC(0)="QEAMZ",DIC="^PSD(58.8,"_NAOU_",1," D ^DIC K DIC Q:Y<0 D
.S PSDRG(+Y)=+$P(Y(0),"^",4)
I '$D(PSDRG)&(X'="^ALL") G END
I X="^ALL" S ALL=1
DATE W ! K %DT S %DT="AEPXR",%DT("A")="Start with Date and Time: " D ^%DT I Y<0 G END
S PSDSD=Y D D^DIQ S PSDATE=Y,%DT("A")="End with Date and Time: " D ^%DT I Y<0 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
W !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
DEV ;sel device
W ! K %ZIS,IOP,IO("Q"),POP S %ZIS="QM" 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^PSDPAT1",ZTDESC="CS PHARM Compile Patient/Drug Activity" D SAVE,^%ZTLOAD K ZTSK G END
U IO G START^PSDPAT1
END ;
D KVAR^VADPT K VA
K %,%DT,%H,%I,%ZIS,ALL,CNT,DA,DATE,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LN,LOOP,NAOU,NAOUN,NODE,NODE9,NUR1,NUR2
K PAT,PG,POP,PSD,PSD1,PSDA,PSDATE,PSDED,PSDOUT,PSDPN,PSDR,PSDRG,PSDRGN,PSDSD,TYP,QTY,SUM,X,Y
K ^TMP("PSDPAT",$J),^TMP("PSDPATL",$J),ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
SAVE ;sets variables for queueing
S (ZTSAVE("NAOU"),ZTSAVE("NAOUN"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"),ZTSAVE("PSDIO"),ZTSAVE("SUM"))=""
S:$D(ALL) ZTSAVE("ALL")="" S:$D(PSDRG) ZTSAVE("PSDRG(")=""
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDPAT 3096 printed Nov 22, 2024@16:58:04 Page 2
PSDPAT ;B'ham ISC/BJW - Prt Data from TRAKKER (Patient/Drug) ; 11 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 RNURSE",DUZ)):1,$DATA(^XUSEC("PSD NURSE",DUZ)):1,1:0)
+5 ;I 'OK W $C(7),!!,"Contact your Nursing ADP Coordinator for access to display the Dispensing Report.",!! K OK Q
SUM ;ask detail or summary
+1 KILL DA,DIR,DIRUT
SET DIR(0)="SO^D:DETAIL LISTING ONLY;S:SUMMARY LISTING ONLY"
+2 SET DIR("A")="Select Dispensing Report(s) to Print"
+3 SET DIR("?",1)="Answer 'D' to print only the transaction detail for this report,"
SET DIR("?",2)="answer 'S' to print only the summary totals or <RET> to quit."
+4 DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO END
SET SUM=Y
ASKN ;select NAOU for report
+1 KILL DA,DIC
+2 SET DIC=58.8
SET DIC(0)="QEA"
SET DIC("A")="Select NAOU: "
SET DIC("B")=$GET(NAOUN)
+3 SET DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)"
+4 DO ^DIC
KILL DIC
if Y<0
GOTO END
SET NAOU=+Y
SET NAOUN=$PIECE(Y,"^",2)
+5 IF '+$PIECE($GET(^PSD(58.8,NAOU,2)),"^",5)
WRITE !!,"This NAOU does not maintain a perpetual inventory balance to list",!,"Dispensing data.",!!
KILL NAOU,NAOUN
GOTO ASKN
CHKD IF '$ORDER(^PSD(58.8,NAOU,1,0))
WRITE !!,"There are no CS stocked drugs for the NAOU you selected.",!!
GOTO ASKN
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,NAOU,1,Y,0),""^"",14)]"""",$P(^(0),""^"",14)'>DT W $C(7),"" *** INACTIVE ***"""
SET DA(1)=+NAOU
SET DIC(0)="QEAMZ"
SET DIC="^PSD(58.8,"_NAOU_",1,"
DO ^DIC
KILL DIC
if Y<0
QUIT
Begin DoDot:1
+4 SET PSDRG(+Y)=+$PIECE(Y(0),"^",4)
End DoDot:1
+5 IF '$DATA(PSDRG)&(X'="^ALL")
GOTO END
+6 IF X="^ALL"
SET ALL=1
DATE WRITE !
KILL %DT
SET %DT="AEPXR"
SET %DT("A")="Start with Date and Time: "
DO ^%DT
IF Y<0
GOTO END
+1 SET PSDSD=Y
DO D^DIQ
SET PSDATE=Y
SET %DT("A")="End with Date and Time: "
DO ^%DT
IF Y<0
GOTO END
+2 IF Y<PSDSD
WRITE !!,"The ending date of the range must be later than the starting date."
GOTO DATE
+3 SET PSDED=Y
DO D^DIQ
SET PSDATE=PSDATE_"^"_Y
SET PSDSD=PSDSD-.0001
SET PSDED=PSDED+.0001
+4 WRITE !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
DEV ;sel device
+1 WRITE !
KILL %ZIS,IOP,IO("Q"),POP
SET %ZIS="QM"
DO ^%ZIS
IF POP
WRITE !!,"NO DEVICE SELECTED OR REPORT PRINTED!!",!
GOTO END
+2 IF $DATA(IO("Q"))
KILL IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDPAT1"
SET ZTDESC="CS PHARM Compile Patient/Drug Activity"
DO SAVE
DO ^%ZTLOAD
KILL ZTSK
GOTO END
+3 USE IO
GOTO START^PSDPAT1
END ;
+1 DO KVAR^VADPT
KILL VA
+2 KILL %,%DT,%H,%I,%ZIS,ALL,CNT,DA,DATE,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LN,LOOP,NAOU,NAOUN,NODE,NODE9,NUR1,NUR2
+3 KILL PAT,PG,POP,PSD,PSD1,PSDA,PSDATE,PSDED,PSDOUT,PSDPN,PSDR,PSDRG,PSDRGN,PSDSD,TYP,QTY,SUM,X,Y
+4 KILL ^TMP("PSDPAT",$JOB),^TMP("PSDPATL",$JOB),ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+5 DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
+6 QUIT
SAVE ;sets variables for queueing
+1 SET (ZTSAVE("NAOU"),ZTSAVE("NAOUN"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"),ZTSAVE("PSDIO"),ZTSAVE("SUM"))=""
+2 if $DATA(ALL)
SET ZTSAVE("ALL")=""
if $DATA(PSDRG)
SET ZTSAVE("PSDRG(")=""
+3 QUIT