- PSDPWK ;BIR/JPW,BJW-Print Pharm Disp. Worksheet ; 3 Aug 98
- ;;3.0; CONTROLLED SUBSTANCES ;**10,69**;13 Feb 97;Build 13
- ;refer to nois#:sdc-0597-60187
- ;References to ^PSD(58.8, covered by DBIA2711
- ;
- I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
- S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,$D(^XUSEC("PSD TECH ADV",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, PSJ PHARM TECH or PSD TECH ADV security key required.",! K OK Q
- W !!,"=> This report lists all pending CS requests for a dispensing site.",!!
- I '$O(^PSD(58.85,0)) W $C(7),!!,"There are no pending request orders.",!! K OK Q
- SUM ;ask worksheet, summary or both
- K DA,DIR,DIRUT S DIR(0)="SO^W:WORKSHEET ONLY;S:SUMMARY TOTALS ONLY;B:BOTH WORKSHEET AND SUMMARY TOTALS"
- S DIR("A")="Select Worksheet Report(s) to Print"
- S DIR("?",1)="Answer 'W' to print only the worksheet for this report,",DIR("?",2)="answer 'S' to print only the summary totals, or",DIR("?")="answer 'B' to print the worksheet and the summary totals."
- D ^DIR K DIR G:$D(DIRUT) END S SUM=Y
- ASKD ;ask disp location
- S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
- I $P(PSDSITE,U,5) S PSDS=PSDS_"^"_+$P(^PSD(58.8,+PSDS,0),"^",5) G CHKD
- W ! 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)",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),PSDS=PSDS_"^"_+$P(Y(0),"^",5)
- S $P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
- CHKD I '$O(^PSD(58.85,"AE",+PSDS,0)) W !!,"There are no pending CS requests for "_PSDSN_".",!! G END
- 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
- I $D(DIRUT),X="^ALL" S ALL=1,CNT=0,SEL="N" D NOW^%DTC S PSDT=X G SORT
- I $D(DIRUT) G END
- S SEL=Y D NOW^%DTC S PSDT=X K DA,DIC S CNT=0
- I SEL="G" D GROUP G:'$D(PSDG) END G SORT
- 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
- SORT ;asks sort
- S ANS=$P($G(^PSD(58.8,+PSDS,2)),"^",7)
- I (ANS="D")!(ANS="N") G DEV
- 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 worksheet sorted by DRUG then NAOU",DIR("?")="Enter 'N' to print the worksheet sorted by NAOU then DRUG."
- S DIR("A")="Select SORT ORDER for Worksheet" D ^DIR K DIR G:$D(DIRUT) END S ANS=Y
- DEV ;ask device and queue info
- ;chgd L4 to s psdio=ion_";"_iost
- 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_";"_IOST,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDPWK1",ZTDESC="Compile Worksheet for CS PHARM" D SAVE,^%ZTLOAD K ZTSK G END
- U IO G START^PSDPWK1
- END K %,%H,%I,%ZIS,ALL,ANS,C,CNT,COMM,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IO("Q"),JJ,JJ1,JJDA,LOOP,LOOP2,NAOU,NODE,OK,ORD,ORDN
- K POP,PRT,PSD,PSDCPY,PSDEV,PSDG,PSDIO,PSDN,PSDNA,PSDR,PSDRN,PSDS,PSDSN,PSDT
- K QTY,SEL,SUM,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK,^TMP("PSDWK",$J),^TMP("PSDWKT",$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("PSDT"),ZTSAVE("PSDIO"),ZTSAVE("ANS"),ZTSAVE("CNT"),ZTSAVE("PSDS"),ZTSAVE("PSDSN"),ZTSAVE("SUM"),ZTSAVE("PSDSITE"))=""
- S:$D(PSDG) ZTSAVE("PSDG(")="" S:$D(NAOU) ZTSAVE("NAOU(")="" S:$D(ALL) ZTSAVE("ALL")=""
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDPWK 4290 printed Feb 18, 2025@23:14:41 Page 2
- PSDPWK ;BIR/JPW,BJW-Print Pharm Disp. Worksheet ; 3 Aug 98
- +1 ;;3.0; CONTROLLED SUBSTANCES ;**10,69**;13 Feb 97;Build 13
- +2 ;refer to nois#:sdc-0597-60187
- +3 ;References to ^PSD(58.8, covered by DBIA2711
- +4 ;
- +5 IF '$DATA(PSDSITE)
- DO ^PSDSET
- if '$DATA(PSDSITE)
- QUIT
- +6 SET OK=$SELECT($DATA(^XUSEC("PSJ RPHARM",DUZ)):1,$DATA(^XUSEC("PSJ PHARM TECH",DUZ)):1,$DATA(^XUSEC("PSD TECH ADV",DUZ)):1,1:0)
- +7 IF 'OK
- WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"process/dispense narcotic supplies.",!!,"PSJ RPHARM, PSJ PHARM TECH or PSD TECH ADV security key required.",!
- KILL OK
- QUIT
- +8 WRITE !!,"=> This report lists all pending CS requests for a dispensing site.",!!
- +9 IF '$ORDER(^PSD(58.85,0))
- WRITE $CHAR(7),!!,"There are no pending request orders.",!!
- KILL OK
- QUIT
- SUM ;ask worksheet, summary or both
- +1 KILL DA,DIR,DIRUT
- SET DIR(0)="SO^W:WORKSHEET ONLY;S:SUMMARY TOTALS ONLY;B:BOTH WORKSHEET AND SUMMARY TOTALS"
- +2 SET DIR("A")="Select Worksheet Report(s) to Print"
- +3 SET DIR("?",1)="Answer 'W' to print only the worksheet for this report,"
- SET DIR("?",2)="answer 'S' to print only the summary totals, or"
- SET DIR("?")="answer 'B' to print the worksheet and the summary totals."
- +4 DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- SET SUM=Y
- ASKD ;ask disp location
- +1 SET PSDS=$PIECE(PSDSITE,U,3)
- SET PSDSN=$PIECE(PSDSITE,U,4)
- +2 IF $PIECE(PSDSITE,U,5)
- SET PSDS=PSDS_"^"_+$PIECE(^PSD(58.8,+PSDS,0),"^",5)
- GOTO CHKD
- +3 WRITE !
- 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)"
- SET DIC("A")="Select Primary Dispensing Site: "
- SET DIC("B")=$PIECE(PSDSITE,U,4)
- +4 DO ^DIC
- KILL DIC
- if Y<0
- GOTO END
- +5 SET PSDS=+Y
- SET PSDSN=$PIECE(Y,"^",2)
- SET PSDS=PSDS_"^"_+$PIECE(Y(0),"^",5)
- +6 SET $PIECE(PSDSITE,U,3)=+Y
- SET $PIECE(PSDSITE,U,4)=PSDSN
- CHKD IF '$ORDER(^PSD(58.85,"AE",+PSDS,0))
- WRITE !!,"There are no pending CS requests for "_PSDSN_".",!!
- GOTO END
- 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
- +5 IF $DATA(DIRUT)
- IF X="^ALL"
- SET ALL=1
- SET CNT=0
- SET SEL="N"
- DO NOW^%DTC
- SET PSDT=X
- GOTO SORT
- +6 IF $DATA(DIRUT)
- GOTO END
- +7 SET SEL=Y
- DO NOW^%DTC
- SET PSDT=X
- KILL DA,DIC
- SET CNT=0
- +8 IF SEL="G"
- DO GROUP
- if '$DATA(PSDG)
- GOTO END
- GOTO SORT
- +9 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
- +10 SET NAOU(+Y)=""
- SET CNT=CNT+1
- End DoDot:1
- +11 IF '$DATA(NAOU)&(X'="^ALL")
- GOTO END
- +12 if X="^ALL"
- SET ALL=1
- SORT ;asks sort
- +1 SET ANS=$PIECE($GET(^PSD(58.8,+PSDS,2)),"^",7)
- +2 IF (ANS="D")!(ANS="N")
- GOTO DEV
- +3 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."
- +4 SET DIR("?",1)="Enter 'D' to print the worksheet sorted by DRUG then NAOU"
- SET DIR("?")="Enter 'N' to print the worksheet sorted by NAOU then DRUG."
- +5 SET DIR("A")="Select SORT ORDER for Worksheet"
- DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- SET ANS=Y
- DEV ;ask device and queue info
- +1 ;chgd L4 to s psdio=ion_";"_iost
- +2 WRITE !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
- +3 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
- +4 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
- +5 IF $DATA(IO("Q"))
- KILL IO("Q")
- SET PSDIO=ION_";"_IOST
- SET ZTIO=""
- KILL ZTSAVE,ZTDTH,ZTSK
- SET ZTRTN="START^PSDPWK1"
- SET ZTDESC="Compile Worksheet for CS PHARM"
- DO SAVE
- DO ^%ZTLOAD
- KILL ZTSK
- GOTO END
- +6 USE IO
- GOTO START^PSDPWK1
- END KILL %,%H,%I,%ZIS,ALL,ANS,C,CNT,COMM,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IO("Q"),JJ,JJ1,JJDA,LOOP,LOOP2,NAOU,NODE,OK,ORD,ORDN
- +1 KILL POP,PRT,PSD,PSDCPY,PSDEV,PSDG,PSDIO,PSDN,PSDNA,PSDR,PSDRN,PSDS,PSDSN,PSDT
- +2 KILL QTY,SEL,SUM,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK,^TMP("PSDWK",$JOB),^TMP("PSDWKT",$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("PSDT"),ZTSAVE("PSDIO"),ZTSAVE("ANS"),ZTSAVE("CNT"),ZTSAVE("PSDS"),ZTSAVE("PSDSN"),ZTSAVE("SUM"),ZTSAVE("PSDSITE"))=""
- +1 if $DATA(PSDG)
- SET ZTSAVE("PSDG(")=""
- if $DATA(NAOU)
- SET ZTSAVE("NAOU(")=""
- if $DATA(ALL)
- SET ZTSAVE("ALL")=""
- +2 QUIT