PSDPLOG2 ;BIR/JPW -Inspector's Log (cont'd) ;2 Aug 94
;;3.0;CONTROLLED SUBSTANCES;**73**;13 Feb 97;Build 8
PRINT ;print inspector's log by naou, drug and green sheet #
S (PG,PSDOUT,NAOU)=0 D NOW^%DTC S Y=+$E(%,1,12) X ^DD("DD") S RPDT=Y
K LN S $P(LN,"-",132)="" I '$D(^TMP("PSDLOG",$J)) D HDR W !!,?45,"**** NO PENDING NARCOTIC ORDERS FOR INSPECTION ****",! G DONE
S NAOU="" F S NAOU=$O(^TMP("PSDLOG",$J,NAOU)) Q:NAOU=""!(PSDOUT) D HDR Q:PSDOUT W !,?2,"=> NAOU: ",NAOU,! S LNUM=$Y D Q:PSDOUT D PRT
.I ASKN D LOOP2 Q
.S PSDRN="" F S PSDRN=$O(^TMP("PSDLOG",$J,NAOU,PSDRN)) Q:PSDRN=""!(PSDOUT) D Q:PSDOUT
..I $Y+8>IOSL D PRT,HDR Q:PSDOUT W !,?2,"=> NAOU: ",NAOU,! S LNUM=$Y
..S NUM="" F S NUM=$O(^TMP("PSDLOG",$J,NAOU,PSDRN,NUM)) Q:NUM=""!(PSDOUT) F PSDCNT=0:0 S PSDCNT=$O(^TMP("PSDLOG",$J,NAOU,PSDRN,NUM,PSDCNT)) Q:'PSDCNT!(PSDOUT) D Q:PSDOUT
...I $Y+8>IOSL D PRT,HDR Q:PSDOUT W !,?2,"=> NAOU: ",NAOU,! S LNUM=$Y
...S NODE=$G(^TMP("PSDLOG",$J,NAOU,PSDRN,NUM,PSDCNT))
...W !,$P(NODE,"^",4),?2,$S(ASK="N":PSDRN,1:NUM),?13,$S(ASK="D":PSDRN,1:NUM),$$SCH($P(NODE,"^",6)),?65,$P(NODE,"^",2),?72,$J($P(NODE,"^"),6),?91,$P(NODE,"^",3),?104,"____________",?118,"____________",!
...S LNUM=$Y
DONE I $E(IOST)'="C" W @IOF
I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR,DIRUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu" D ^DIR K DIR
END K %,%DT,%H,%I,%ZIS,ALL,ANS,ASK,ASKN,CNT,COMM,DA,DIC,DIE,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,EXP,EXPD,JJ,LN,LNUM,LOOP,LOT,MFG,NAOU,NODE,NODE3,NUM
K OK,ORD,ORDN,PG,PSD,PSDA,PSDCNT,PSDDT,PSDG,PSDIO,PSDOK,PSDN,PSDNA,PSDOUT,PSDR,PSDRN,PSDSD,PSDST,PSDT,PSDTR,QTY,REQD,REQDT,RPDT,RQTY
K SEL,STAT,STATN,TEXT,TYP,TYPN,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDLOG",$J) D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@"
Q
HDR ;header for log
I $E(IOST,1,2)="C-",PG W ! K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
S PG=PG+1 W:$Y @IOF W !,?42,"Inspector's Log for Controlled Substances",?120,"Page: ",PG,!,?52,RPDT,!
W !,?67,"DATE",?80,"QTY"
W !,"DISP #",?13,"DRUG",?65,"DISPENSED",?78,"DISPENSED",?91,"EXP DATE",?104,"QTY ON HAND",?118,"NAME/DATE"
W !,LN,!
Q
LOOP2 ;print inv typ loop
S TYPN="" F S TYPN=$O(^TMP("PSDLOG",$J,NAOU,TYPN)) Q:TYPN=""!(PSDOUT) W !,?4,"=> INVENTORY TYPE: ",$S($E(TYPN,1,2)="ZZ":$E(TYPN,3,99),1:TYPN),! S LNUM=$Y D
.S PSDRN="" F S PSDRN=$O(^TMP("PSDLOG",$J,NAOU,TYPN,PSDRN)) Q:PSDRN=""!(PSDOUT) D Q:PSDOUT
..I $Y+8>IOSL D PRT,HDR Q:PSDOUT W !,?2,"=> NAOU: ",NAOU,! W:ASKN !,?4,"=> INVENTORY TYPE: ",$S($E(TYPN,1,2)="ZZ":$E(TYPN,3,99),1:TYPN),! S LNUM=$Y
..S NUM="" F S NUM=$O(^TMP("PSDLOG",$J,NAOU,TYPN,PSDRN,NUM)) Q:NUM=""!(PSDOUT) F PSDCNT=0:0 S PSDCNT=$O(^TMP("PSDLOG",$J,NAOU,TYPN,PSDRN,NUM,PSDCNT)) Q:'PSDCNT!(PSDOUT) D Q:PSDOUT
...I $Y+8>IOSL D PRT,HDR Q:PSDOUT W !,?2,"=> NAOU: ",NAOU,! W:ASKN !,?4,"=> INVENTORY TYPE: ",TYPN,! S LNUM=$Y
...S NODE=$G(^TMP("PSDLOG",$J,NAOU,TYPN,PSDRN,NUM,PSDCNT))
...W !,$P(NODE,"^",4),?2,$S(ASK="N":PSDRN,1:NUM),?13,$S(ASK="D":PSDRN,1:NUM),$$SCH($P(NODE,"^",6)),?65,$P(NODE,"^",2),?72,$J($P(NODE,"^"),6),?91,$P(NODE,"^",3),?104,"____________",?118,"____________",!
...S LNUM=$Y
Q
PRT ;
I LNUM<IOSL-7 F JJ=LNUM:1:IOSL-7 W !
W LN,!,"* - Transferred to another NAOU but not yet received",!,"** - Filled not yet received",!,"# - Returned to Stock",!
Q
SCH(X) ;schedule conversion
N DEA
S DEA=+$P($G(^PSDRUG(X,0)),"^",3)
Q:+DEA<1 ""
Q " (Schedule "_$P("I^II^III^IV^V","^",DEA)_")"
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDPLOG2 3507 printed Dec 13, 2024@01:48:05 Page 2
PSDPLOG2 ;BIR/JPW -Inspector's Log (cont'd) ;2 Aug 94
+1 ;;3.0;CONTROLLED SUBSTANCES;**73**;13 Feb 97;Build 8
PRINT ;print inspector's log by naou, drug and green sheet #
+1 SET (PG,PSDOUT,NAOU)=0
DO NOW^%DTC
SET Y=+$EXTRACT(%,1,12)
XECUTE ^DD("DD")
SET RPDT=Y
+2 KILL LN
SET $PIECE(LN,"-",132)=""
IF '$DATA(^TMP("PSDLOG",$JOB))
DO HDR
WRITE !!,?45,"**** NO PENDING NARCOTIC ORDERS FOR INSPECTION ****",!
GOTO DONE
+3 SET NAOU=""
FOR
SET NAOU=$ORDER(^TMP("PSDLOG",$JOB,NAOU))
if NAOU=""!(PSDOUT)
QUIT
DO HDR
if PSDOUT
QUIT
WRITE !,?2,"=> NAOU: ",NAOU,!
SET LNUM=$Y
Begin DoDot:1
+4 IF ASKN
DO LOOP2
QUIT
+5 SET PSDRN=""
FOR
SET PSDRN=$ORDER(^TMP("PSDLOG",$JOB,NAOU,PSDRN))
if PSDRN=""!(PSDOUT)
QUIT
Begin DoDot:2
+6 IF $Y+8>IOSL
DO PRT
DO HDR
if PSDOUT
QUIT
WRITE !,?2,"=> NAOU: ",NAOU,!
SET LNUM=$Y
+7 SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDLOG",$JOB,NAOU,PSDRN,NUM))
if NUM=""!(PSDOUT)
QUIT
FOR PSDCNT=0:0
SET PSDCNT=$ORDER(^TMP("PSDLOG",$JOB,NAOU,PSDRN,NUM,PSDCNT))
if 'PSDCNT!(PSDOUT)
QUIT
Begin DoDot:3
+8 IF $Y+8>IOSL
DO PRT
DO HDR
if PSDOUT
QUIT
WRITE !,?2,"=> NAOU: ",NAOU,!
SET LNUM=$Y
+9 SET NODE=$GET(^TMP("PSDLOG",$JOB,NAOU,PSDRN,NUM,PSDCNT))
+10 WRITE !,$PIECE(NODE,"^",4),?2,$SELECT(ASK="N":PSDRN,1:NUM),?13,$SELECT(ASK="D":PSDRN,1:NUM),$$SCH($PIECE(NODE,"^",6)),?65,$PIECE(NODE,"^",2),?72,$JUSTIFY($PIECE(NODE,"^"),6),?91,$PIECE(NODE,"^",3),?104,"____________"
,?118,"____________",!
+11 SET LNUM=$Y
End DoDot:3
if PSDOUT
QUIT
End DoDot:2
if PSDOUT
QUIT
End DoDot:1
if PSDOUT
QUIT
DO PRT
DONE IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST,1,2)="C-"
IF 'PSDOUT
WRITE !
KILL DIR,DIRUT
SET DIR(0)="EA"
SET DIR("A")="END OF REPORT! Press <RET> to return to the menu"
DO ^DIR
KILL DIR
END KILL %,%DT,%H,%I,%ZIS,ALL,ANS,ASK,ASKN,CNT,COMM,DA,DIC,DIE,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,EXP,EXPD,JJ,LN,LNUM,LOOP,LOT,MFG,NAOU,NODE,NODE3,NUM
+1 KILL OK,ORD,ORDN,PG,PSD,PSDA,PSDCNT,PSDDT,PSDG,PSDIO,PSDOK,PSDN,PSDNA,PSDOUT,PSDR,PSDRN,PSDSD,PSDST,PSDT,PSDTR,QTY,REQD,REQDT,RPDT,RQTY
+2 KILL SEL,STAT,STATN,TEXT,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
HDR ;header for log
+1 IF $EXTRACT(IOST,1,2)="C-"
IF PG
WRITE !
KILL DA,DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET PSDOUT=1
QUIT
+2 SET PG=PG+1
if $Y
WRITE @IOF
WRITE !,?42,"Inspector's Log for Controlled Substances",?120,"Page: ",PG,!,?52,RPDT,!
+3 WRITE !,?67,"DATE",?80,"QTY"
+4 WRITE !,"DISP #",?13,"DRUG",?65,"DISPENSED",?78,"DISPENSED",?91,"EXP DATE",?104,"QTY ON HAND",?118,"NAME/DATE"
+5 WRITE !,LN,!
+6 QUIT
LOOP2 ;print inv typ loop
+1 SET TYPN=""
FOR
SET TYPN=$ORDER(^TMP("PSDLOG",$JOB,NAOU,TYPN))
if TYPN=""!(PSDOUT)
QUIT
WRITE !,?4,"=> INVENTORY TYPE: ",$SELECT($EXTRACT(TYPN,1,2)="ZZ":$EXTRACT(TYPN,3,99),1:TYPN),!
SET LNUM=$Y
Begin DoDot:1
+2 SET PSDRN=""
FOR
SET PSDRN=$ORDER(^TMP("PSDLOG",$JOB,NAOU,TYPN,PSDRN))
if PSDRN=""!(PSDOUT)
QUIT
Begin DoDot:2
+3 IF $Y+8>IOSL
DO PRT
DO HDR
if PSDOUT
QUIT
WRITE !,?2,"=> NAOU: ",NAOU,!
if ASKN
WRITE !,?4,"=> INVENTORY TYPE: ",$SELECT($EXTRACT(TYPN,1,2)="ZZ":$EXTRACT(TYPN,3,99),1:TYPN),!
SET LNUM=$Y
+4 SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDLOG",$JOB,NAOU,TYPN,PSDRN,NUM))
if NUM=""!(PSDOUT)
QUIT
FOR PSDCNT=0:0
SET PSDCNT=$ORDER(^TMP("PSDLOG",$JOB,NAOU,TYPN,PSDRN,NUM,PSDCNT))
if 'PSDCNT!(PSDOUT)
QUIT
Begin DoDot:3
+5 IF $Y+8>IOSL
DO PRT
DO HDR
if PSDOUT
QUIT
WRITE !,?2,"=> NAOU: ",NAOU,!
if ASKN
WRITE !,?4,"=> INVENTORY TYPE: ",TYPN,!
SET LNUM=$Y
+6 SET NODE=$GET(^TMP("PSDLOG",$JOB,NAOU,TYPN,PSDRN,NUM,PSDCNT))
+7 WRITE !,$PIECE(NODE,"^",4),?2,$SELECT(ASK="N":PSDRN,1:NUM),?13,$SELECT(ASK="D":PSDRN,1:NUM),$$SCH($PIECE(NODE,"^",6)),?65,$PIECE(NODE,"^",2),?72,$JUSTIFY($PIECE(NODE,"^"),6),?91,$PIECE(NODE,"^",3),?104,"____________"
,?118,"____________",!
+8 SET LNUM=$Y
End DoDot:3
if PSDOUT
QUIT
End DoDot:2
if PSDOUT
QUIT
End DoDot:1
+9 QUIT
PRT ;
+1 IF LNUM<IOSL-7
FOR JJ=LNUM:1:IOSL-7
WRITE !
+2 WRITE LN,!,"* - Transferred to another NAOU but not yet received",!,"** - Filled not yet received",!,"# - Returned to Stock",!
+3 QUIT
SCH(X) ;schedule conversion
+1 NEW DEA
+2 SET DEA=+$PIECE($GET(^PSDRUG(X,0)),"^",3)
+3 if +DEA<1
QUIT ""
+4 QUIT " (Schedule "_$PIECE("I^II^III^IV^V","^",DEA)_")"