- PSDNU ;BIR/BJW-Usage Report for NAOUs ; 13 Nov 17
- ;;3.0;CONTROLLED SUBSTANCES;**8,82**;13 Feb 97;Build 3
- ;**Y2K compliance**,"P" added to date input string
- I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
- I '$D(^XUSEC("PSJ RPHARM",DUZ))&('$D(^XUSEC("PSD TECH ADV",DUZ))) D G END ; PSD*3.0*82 changes this and next 3 lines
- . W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to print"
- . W !,?12,"the narcotic NAOU Usage Report."
- . W !!,"PSJ RPHARM or PSD TECH ADV security key is required.",!
- W !!,"Select Date Range for NAOU Usage Report",!
- DATE ;ask date range
- W ! K %DT S %DT="AEP",%DT("A")="Start with Date: " D ^%DT I Y<0 S PSDOUT=1 G END
- S PSDSD=Y D D^DIQ S PSDATE=Y,%DT("A")="End with Date: " 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+.9999
- D NOW^%DTC S PSDT=X
- SUM ;if summary only
- W ! K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Do you want to print the summary totals only",DIR("B")="NO"
- S DIR("?",1)="Answer 'YES' to print only the summary totals for this report,",DIR("?")="answer 'NO' to print the detail report including summary totals."
- D ^DIR K DIR G:$D(DIRUT) END S SUM=Y
- SORT ;sel sort order
- K DA,DIR,DIRUT S DIR(0)="SO^D:DRUG/ALL NAOUS;N:NAOU/ALL DRUGS",DIR("A",1)="You may print by either of these sorting methods."
- S DIR("?",1)="Enter 'D' if you wish to print the NAOU Usage Report sorted by DRUG",DIR("?",2)=" and within DRUG by each NAOU."
- S DIR("?",3)="Enter 'N' to print the NAOU Usage Report by NAOU",DIR("?")=" and within NAOU by each DRUG."
- S DIR("A")="Select SORT ORDER for Report" D ^DIR K DIR G:$D(DIRUT) END S ANS=Y
- G:ANS="D" DRUG
- ASKN ;ask NAOU(s)
- W !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
- K DA,DIC
- 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),""^"",2)=""N"",$P(^(0),""^"",3)=+PSDSITE" D ^DIC K DIC Q:Y<0 S LOC(+Y)=""
- I '$D(LOC)&(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)="N",$P($G(^(0)),"^",3)=+PSDSITE S LOC(PSD)=""
- G DEV
- DRUG ;ask drug(s)
- W !!,?5,"You may select a single drug, several drugs,",!,?5,"or enter ^ALL to select all drugs.",!!
- K DA,DIC F S DIC("A")="Select DRUG: ",DIC=50,DIC(0)="QEAM",DIC("S")="I $S('$D(^(""I"")):1,+^(""I"")>DT:1,1:0),$P($G(^(2)),""^"",3)[""N""" D ^DIC K DIC Q:Y<0 S LOC(+Y)=""
- I '$D(LOC)&(X'="^ALL") G END
- I X="^ALL" S ALL=1
- DEV ;asks device and queueing information
- W !!,"This report is designed for a 80 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"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN=$S(ANS="D":"START^PSDNU1",1:"START^PSDNU2"),ZTDESC="CS PHARM NAOU Usage Report" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
- U IO G:ANS="D" START^PSDNU1 G:ANS="N" START^PSDNU2
- END ;
- K %,%DT,%H,%I,%ZIS,ALL,ANS,DA,DATE,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IO("Q"),LOC
- K POP,PSD,PSDATE,PSDED,PSDOUT,PSDSD,PSDT,SUM,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE D ^%ZISC
- S:$D(ZTQUEUED) ZTREQ="@"
- Q
- SAVE ;save variables for queueing
- S ZTSAVE("ANS")="",ZTSAVE("SUM")="",ZTSAVE("PSDSITE")="",ZTSAVE("PSD")="",ZTSAVE("PSDT")="" S:$D(LOC) ZTSAVE("LOC(")=""
- S:$D(ALL) ZTSAVE("ALL")=""
- S (ZTSAVE("PSDATE"),ZTSAVE("PSDED"),ZTSAVE("PSDSD"))=""
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDNU 3622 printed Feb 18, 2025@23:13:36 Page 2
- PSDNU ;BIR/BJW-Usage Report for NAOUs ; 13 Nov 17
- +1 ;;3.0;CONTROLLED SUBSTANCES;**8,82**;13 Feb 97;Build 3
- +2 ;**Y2K compliance**,"P" added to date input string
- +3 IF '$DATA(PSDSITE)
- DO ^PSDSET
- if '$DATA(PSDSITE)
- QUIT
- +4 ; PSD*3.0*82 changes this and next 3 lines
- IF '$DATA(^XUSEC("PSJ RPHARM",DUZ))&('$DATA(^XUSEC("PSD TECH ADV",DUZ)))
- Begin DoDot:1
- +5 WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to print"
- +6 WRITE !,?12,"the narcotic NAOU Usage Report."
- +7 WRITE !!,"PSJ RPHARM or PSD TECH ADV security key is required.",!
- End DoDot:1
- GOTO END
- +8 WRITE !!,"Select Date Range for NAOU Usage Report",!
- DATE ;ask date range
- +1 WRITE !
- KILL %DT
- SET %DT="AEP"
- SET %DT("A")="Start with Date: "
- DO ^%DT
- IF Y<0
- SET PSDOUT=1
- GOTO END
- +2 SET PSDSD=Y
- DO D^DIQ
- SET PSDATE=Y
- SET %DT("A")="End with Date: "
- DO ^%DT
- IF Y<0
- SET PSDOUT=1
- GOTO END
- +3 IF Y<PSDSD
- WRITE !!,"The ending date of the range must be later than the starting date."
- GOTO DATE
- +4 SET PSDED=Y
- DO D^DIQ
- SET PSDATE=PSDATE_"^"_Y
- SET PSDSD=PSDSD-.0001
- SET PSDED=PSDED+.9999
- +5 DO NOW^%DTC
- SET PSDT=X
- SUM ;if summary only
- +1 WRITE !
- KILL DA,DIR,DIRUT
- SET DIR(0)="Y"
- SET DIR("A")="Do you want to print the summary totals only"
- SET DIR("B")="NO"
- +2 SET DIR("?",1)="Answer 'YES' to print only the summary totals for this report,"
- SET DIR("?")="answer 'NO' to print the detail report including summary totals."
- +3 DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- SET SUM=Y
- SORT ;sel sort order
- +1 KILL DA,DIR,DIRUT
- SET DIR(0)="SO^D:DRUG/ALL NAOUS;N:NAOU/ALL DRUGS"
- SET DIR("A",1)="You may print by either of these sorting methods."
- +2 SET DIR("?",1)="Enter 'D' if you wish to print the NAOU Usage Report sorted by DRUG"
- SET DIR("?",2)=" and within DRUG by each NAOU."
- +3 SET DIR("?",3)="Enter 'N' to print the NAOU Usage Report by NAOU"
- SET DIR("?")=" and within NAOU by each DRUG."
- +4 SET DIR("A")="Select SORT ORDER for Report"
- DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- SET ANS=Y
- +5 if ANS="D"
- GOTO DRUG
- ASKN ;ask NAOU(s)
- +1 WRITE !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
- +2 KILL DA,DIC
- +3 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),""^"",2)=""N"",$P(^(0),""^"",3)=+PSDSITE"
- DO ^DIC
- KILL DIC
- if Y<0
- QUIT
- SET LOC(+Y)=""
- +4 IF '$DATA(LOC)&(X'="^ALL")
- GOTO END
- +5 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)="N"
- IF $PIECE($GET(^(0)),"^",3)=+PSDSITE
- SET LOC(PSD)=""
- +6 GOTO DEV
- DRUG ;ask drug(s)
- +1 WRITE !!,?5,"You may select a single drug, several drugs,",!,?5,"or enter ^ALL to select all drugs.",!!
- +2 KILL DA,DIC
- FOR
- SET DIC("A")="Select DRUG: "
- SET DIC=50
- SET DIC(0)="QEAM"
- SET DIC("S")="I $S('$D(^(""I"")):1,+^(""I"")>DT:1,1:0),$P($G(^(2)),""^"",3)[""N"""
- DO ^DIC
- KILL DIC
- if Y<0
- QUIT
- SET LOC(+Y)=""
- +3 IF '$DATA(LOC)&(X'="^ALL")
- GOTO END
- +4 IF X="^ALL"
- SET ALL=1
- DEV ;asks device and queueing information
- +1 WRITE !!,"This report is designed for a 80 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"),ZTIO,ZTSAVE,ZTDTH,ZTSK
- SET ZTRTN=$SELECT(ANS="D":"START^PSDNU1",1:"START^PSDNU2")
- SET ZTDESC="CS PHARM NAOU Usage Report"
- DO SAVE
- DO ^%ZTLOAD
- DO HOME^%ZIS
- KILL ZTSK
- GOTO END
- +4 USE IO
- if ANS="D"
- GOTO START^PSDNU1
- if ANS="N"
- GOTO START^PSDNU2
- END ;
- +1 KILL %,%DT,%H,%I,%ZIS,ALL,ANS,DA,DATE,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IO("Q"),LOC
- +2 KILL POP,PSD,PSDATE,PSDED,PSDOUT,PSDSD,PSDT,SUM,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE
- DO ^%ZISC
- +3 if $DATA(ZTQUEUED)
- SET ZTREQ="@"
- +4 QUIT
- SAVE ;save variables for queueing
- +1 SET ZTSAVE("ANS")=""
- SET ZTSAVE("SUM")=""
- SET ZTSAVE("PSDSITE")=""
- SET ZTSAVE("PSD")=""
- SET ZTSAVE("PSDT")=""
- if $DATA(LOC)
- SET ZTSAVE("LOC(")=""
- +2 if $DATA(ALL)
- SET ZTSAVE("ALL")=""
- +3 SET (ZTSAVE("PSDATE"),ZTSAVE("PSDED"),ZTSAVE("PSDSD"))=""
- +4 QUIT