- PSDPLOG ;BIR/BJW - CS Inspector's Log ;11 Feb 98
- ;;3.0;CONTROLLED SUBSTANCES;**8,73**;13 Feb 97;Build 8
- ;**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,"print the CS Inspector's Log.",! K OK Q
- W !,?5,"Inspector's Log for Active Green Sheets",!
- RET ;ask to include returns
- K DA,DIR,DIRUT S DIR(0)="Y",DIR("B")="YES",DIR("A")="Include Returns to Stock"
- S DIR("?")="Answer 'YES' or return to include returns to stock, 'NO' to continue without returns, or '^' to quit."
- D ^DIR K DIR I $D(DIRUT) D MSG G END
- S PSDRET=+Y G:'PSDRET ASKN
- RDATE ;ask return date
- W ! K %DT S %DT="AEP",%DT("A")="Start with Date Returned to Stock: " D ^%DT I Y<0 S PSDOUT=1 D MSG G END
- S PSDSD=Y,PSDSD=PSDSD-.0001
- 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 G:$D(DIRUT) 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 SCH
- F S DIC=58.8,DIC("A")="Select NAOU: ",DIC(0)="QEA",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)" 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
- SCH ;ask schedule
- W !!,"All Controlled Substances or Selected Schedules?"
- K DIR
- S DIR(0)="S^1:SCHEDULES I - II;2:SCHEDULES III - V;3:SCHEDULES I - V",DIR("A")="Select Schedule(s)",DIR("B")=3
- D ^DIR
- I $D(DIRUT) G END
- K PSDSCH S I=$S(Y=2:3,1:1),J=$S(Y=1:2,1:5) F K=I:1:J S PSDSCH(K)=""
- K I,J,K
- SORT ;asks sort
- W ! K DA,DIR,DIRUT S DIR(0)="YO",DIR("A")="Do you wish to sort by Inventory Type",DIR("B")="NO"
- S DIR("?")="Answer YES to sort drugs by Inventory Type, NO or <RET> to sort by drug."
- D ^DIR K DIR G:$D(DIRUT) END S ASKN=Y
- SORT2 ;asks second sort
- K DA,DIR,DIRUT S DIR(0)="SO^D:DRUG/DISPENSING #S;N:NUMERIC DISPENSING #S"
- S DIR("A")="Select Print Order for Inspector's Log",DIR("?",1)="Select D to print Dispensing Number numerically by drug, within an NAOU,",DIR("?")="select N to print numerically within an NAOU, or '^' to quit."
- D ^DIR K DIR G:$D(DIRUT) END S ASK=Y
- 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.",!!
- 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_";"_IOST_";"_IOM_";"_IOSL,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDPLOG1",ZTDESC="Compile Narcotic Inspector Log" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
- U IO G START^PSDPLOG1
- END K %,%DT,%H,%I,%ZIS,ALL,ASK,ASKN,CNT,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT,EXP,EXPD,JJ,NAOU,NODE,NODE3,NUM,PSDSCH
- K OK,PSD,PSDA,PSDDT,PSDG,PSDIO,PSDOK,PSDOUT,PSDN,PSDNA,PSDPT,PSDR,PSDRN,PSDRD,PSDRDT,PSDRET,PSDSD,PSDST,PSDT,PSDTR
- K QTY,SEL,STAT,STATN,TYP,TYPN,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
- K ^TMP("PSDLOG",$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("PSDIO"),ZTSAVE("PSDT"),ZTSAVE("CNT"),ZTSAVE("PSDSITE"),ZTSAVE("ASK"),ZTSAVE("ASKN"))="",ZTSAVE("PSDSCH(")=""
- S:$D(PSDG) ZTSAVE("PSDG(")="" S:$D(NAOU) ZTSAVE("NAOU(")="" S:$D(ALL) ZTSAVE("ALL")=""
- S ZTSAVE("PSDRET")="" S:$D(PSDSD) ZTSAVE("PSDSD")=""
- Q
- MSG W !!,"No action taken.",!!
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDPLOG 3895 printed Mar 13, 2025@20:52:44 Page 2
- PSDPLOG ;BIR/BJW - CS Inspector's Log ;11 Feb 98
- +1 ;;3.0;CONTROLLED SUBSTANCES;**8,73**;13 Feb 97;Build 8
- +2 ;**Y2K compliance**,"P" added to date input string
- +3 IF '$DATA(PSDSITE)
- DO ^PSDSET
- if '$DATA(PSDSITE)
- QUIT
- +4 ;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,"print the CS Inspector's Log.",! K OK Q
- +5 WRITE !,?5,"Inspector's Log for Active Green Sheets",!
- RET ;ask to include returns
- +1 KILL DA,DIR,DIRUT
- SET DIR(0)="Y"
- SET DIR("B")="YES"
- SET DIR("A")="Include Returns to Stock"
- +2 SET DIR("?")="Answer 'YES' or return to include returns to stock, 'NO' to continue without returns, or '^' to quit."
- +3 DO ^DIR
- KILL DIR
- IF $DATA(DIRUT)
- DO MSG
- GOTO END
- +4 SET PSDRET=+Y
- if 'PSDRET
- GOTO ASKN
- RDATE ;ask return date
- +1 WRITE !
- KILL %DT
- SET %DT="AEP"
- SET %DT("A")="Start with Date Returned to Stock: "
- DO ^%DT
- IF Y<0
- SET PSDOUT=1
- DO MSG
- GOTO END
- +2 SET PSDSD=Y
- SET PSDSD=PSDSD-.0001
- 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
- if $DATA(DIRUT)
- GOTO END
- SET SEL=Y
- DO NOW^%DTC
- SET PSDT=X
- KILL DA,DIC
- SET CNT=0
- +5 IF SEL="G"
- DO GROUP
- if '$DATA(PSDG)
- GOTO END
- GOTO SCH
- +6 FOR
- SET DIC=58.8
- SET DIC("A")="Select NAOU: "
- SET DIC(0)="QEA"
- SET DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)"
- DO ^DIC
- KILL DIC
- if Y<0
- QUIT
- Begin DoDot:1
- +7 SET NAOU(+Y)=""
- SET CNT=CNT+1
- End DoDot:1
- +8 IF '$DATA(NAOU)&(X'="^ALL")
- GOTO END
- +9 if X="^ALL"
- SET ALL=1
- SCH ;ask schedule
- +1 WRITE !!,"All Controlled Substances or Selected Schedules?"
- +2 KILL DIR
- +3 SET DIR(0)="S^1:SCHEDULES I - II;2:SCHEDULES III - V;3:SCHEDULES I - V"
- SET DIR("A")="Select Schedule(s)"
- SET DIR("B")=3
- +4 DO ^DIR
- +5 IF $DATA(DIRUT)
- GOTO END
- +6 KILL PSDSCH
- SET I=$SELECT(Y=2:3,1:1)
- SET J=$SELECT(Y=1:2,1:5)
- FOR K=I:1:J
- SET PSDSCH(K)=""
- +7 KILL I,J,K
- SORT ;asks sort
- +1 WRITE !
- KILL DA,DIR,DIRUT
- SET DIR(0)="YO"
- SET DIR("A")="Do you wish to sort by Inventory Type"
- SET DIR("B")="NO"
- +2 SET DIR("?")="Answer YES to sort drugs by Inventory Type, NO or <RET> to sort by drug."
- +3 DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- SET ASKN=Y
- SORT2 ;asks second sort
- +1 KILL DA,DIR,DIRUT
- SET DIR(0)="SO^D:DRUG/DISPENSING #S;N:NUMERIC DISPENSING #S"
- +2 SET DIR("A")="Select Print Order for Inspector's Log"
- SET DIR("?",1)="Select D to print Dispensing Number numerically by drug, within an NAOU,"
- SET DIR("?")="select N to print numerically within an NAOU, or '^' to quit."
- +3 DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- SET ASK=Y
- 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 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_";"_IOST_";"_IOM_";"_IOSL
- SET ZTIO=""
- KILL ZTSAVE,ZTDTH,ZTSK
- SET ZTRTN="START^PSDPLOG1"
- SET ZTDESC="Compile Narcotic Inspector Log"
- DO SAVE
- DO ^%ZTLOAD
- DO HOME^%ZIS
- KILL ZTSK
- GOTO END
- +4 USE IO
- GOTO START^PSDPLOG1
- END KILL %,%DT,%H,%I,%ZIS,ALL,ASK,ASKN,CNT,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT,EXP,EXPD,JJ,NAOU,NODE,NODE3,NUM,PSDSCH
- +1 KILL OK,PSD,PSDA,PSDDT,PSDG,PSDIO,PSDOK,PSDOUT,PSDN,PSDNA,PSDPT,PSDR,PSDRN,PSDRD,PSDRDT,PSDRET,PSDSD,PSDST,PSDT,PSDTR
- +2 KILL QTY,SEL,STAT,STATN,TYP,TYPN,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
- +3 KILL ^TMP("PSDLOG",$JOB)
- DO ^%ZISC
- +4 if $DATA(ZTQUEUED)
- SET ZTREQ="@"
- +5 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("PSDIO"),ZTSAVE("PSDT"),ZTSAVE("CNT"),ZTSAVE("PSDSITE"),ZTSAVE("ASK"),ZTSAVE("ASKN"))=""
- SET ZTSAVE("PSDSCH(")=""
- +1 if $DATA(PSDG)
- SET ZTSAVE("PSDG(")=""
- if $DATA(NAOU)
- SET ZTSAVE("NAOU(")=""
- if $DATA(ALL)
- SET ZTSAVE("ALL")=""
- +2 SET ZTSAVE("PSDRET")=""
- if $DATA(PSDSD)
- SET ZTSAVE("PSDSD")=""
- +3 QUIT
- MSG WRITE !!,"No action taken.",!!
- +1 QUIT