PSDNBT ;BIR/JPW-GS Trans Between NAOUs Not Rec Report ; 2 Aug 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
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,"review this narcotics report.",! K OK Q
W !!,"Green Sheets Transferred Between NAOUs Pending Receipt",!!
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"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDNBT",ZTDESC="CS Transfer GS Not Recd Report" S ZTSAVE("PSDSITE")="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;compile data
K ^TMP("PSDNBT",$J)
F JJ=0:0 S JJ=$O(^PSD(58.8,JJ)) Q:'JJ I $D(^PSD(58.8,JJ,0)),$P(^(0),"^",3)=+PSDSITE S NAOU(JJ)=""
F PSD=0:0 S PSD=$O(^PSD(58.81,"AD",10,PSD)) Q:'PSD F PSDA=0:0 S PSDA=$O(^PSD(58.81,"AD",10,PSD,PSDA)) Q:'PSDA I $D(^PSD(58.81,PSDA,0)),$D(^PSD(58.81,PSDA,7)) D
.Q:$D(^PSD(58.81,"AE",PSDA)) S NODE=^PSD(58.81,PSDA,0),PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN")
.S NAOU=+$P(NODE,"^",18) Q:'$D(NAOU(NAOU)) S NAOUN=$S($P($G(^PSD(58.8,NAOU,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_NAOU) I NAOUN'="UNKNOWN"
.Q:'$D(NAOU(NAOU))
.S DRUG=+$P(NODE,"^",5),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_DRUG)
.S NODE7=^PSD(58.81,PSDA,7),QTY=+$P(NODE7,"^",7),NAOUT=$P(NODE7,"^",3),TRFD=+$P(NODE7,"^"),NURSF=+$P(NODE7,"^",2)
.S NAOUTN=$P($G(^PSD(58.8,NAOUT,0)),"^") I TRFD S Y=TRFD X ^DD("DD") S TRFD=Y
.I NURSF S NURSF=$P($G(^VA(200,NURSF,0)),"^"),NURSF=$P(NURSF,",")_","_$E($P(NURSF,",",2))
.S ^TMP("PSDNBT",$J,DRUGN,PSDPN,PSDA)=NAOUTN_"^"_NAOUN_"^"_QTY_"^"_TRFD_"^"_NURSF
PRINT ;print
D NOW^%DTC S Y=X X ^DD("DD") S RPDT=Y
S (PG,PSDOUT)=0
K LN S $P(LN,"-",132)="" I '$D(^TMP("PSDNBT",$J)) D HDR W !!,?30,"**** NO GREEN SHEETS TRANSFERRED BETWEEN NAOUs PENDING RECEIPT ****",! G DONE
D HDR S DRUG="" F S DRUG=$O(^TMP("PSDNBT",$J,DRUG)) Q:DRUG=""!(PSDOUT) W !!,?5,"= > ",DRUG,! D
.S NUM="" F S NUM=$O(^TMP("PSDNBT",$J,DRUG,NUM)) Q:NUM=""!(PSDOUT) F PSD=0:0 S PSD=$O(^TMP("PSDNBT",$J,DRUG,NUM,PSD)) Q:'PSD!(PSDOUT) D
..I $Y+5>IOSL D HDR Q:PSDOUT W !!,?5,"=> ",DRUG,!
..S NODE=^TMP("PSDNBT",$J,DRUG,NUM,PSD) W !,NUM,?12,$P(NODE,"^",4),?38,$E($P(NODE,"^",2),1,25),?60,$J($P(NODE,"^",3),6),?80,$P(NODE,"^",5),?100,$E($P(NODE,"^"),1,30)
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,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DRUG,DRUGN,DUOUT,IO("Q"),JJ,LN,NAOU,NAOUN,NAOUT,NAOUTN,NODE,NODE7,NUM,NURSF
K OK,POP,PG,PHARM,PHARMN,POP,PSD,PSDA,PSDDT,PSDOUT,PSDPN,PSDS,PSDSN,PSDST,QTY,RPDT,TRFD,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDNBT",$J),^TMP("PSDFNDT",$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 !,?25,"GREEN SHEETS TRANSFERRED BETWEEN NAOUs PENDING RECEIPT",?115,"Page: ",PG,!,?40,RPDT,!
W !!,?5,"=> DRUG",!,?16,"DATE",?38,"NAOU",?82,"NURSE",?104,"NAOU"
W !,"DISP #",?11,"TRANSFERRED FROM",?32,"TRANSFERRED FROM",?62,"QUANTITY",?80,"TRANSFERRING",?100,"TRANSFERRED TO",!,LN
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDNBT 3508 printed Dec 13, 2024@01:46:48 Page 2
PSDNBT ;BIR/JPW-GS Trans Between NAOUs Not Rec Report ; 2 Aug 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
+2 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
QUIT
+3 ;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,"review this narcotics report.",! K OK Q
+4 WRITE !!,"Green Sheets Transferred Between NAOUs Pending Receipt",!!
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"),ZTIO,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDNBT"
SET ZTDESC="CS Transfer GS Not Recd Report"
SET ZTSAVE("PSDSITE")=""
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+4 USE IO
START ;compile data
+1 KILL ^TMP("PSDNBT",$JOB)
+2 FOR JJ=0:0
SET JJ=$ORDER(^PSD(58.8,JJ))
if 'JJ
QUIT
IF $DATA(^PSD(58.8,JJ,0))
IF $PIECE(^(0),"^",3)=+PSDSITE
SET NAOU(JJ)=""
+3 FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.81,"AD",10,PSD))
if 'PSD
QUIT
FOR PSDA=0:0
SET PSDA=$ORDER(^PSD(58.81,"AD",10,PSD,PSDA))
if 'PSDA
QUIT
IF $DATA(^PSD(58.81,PSDA,0))
IF $DATA(^PSD(58.81,PSDA,7))
Begin DoDot:1
+4 if $DATA(^PSD(58.81,"AE",PSDA))
QUIT
SET NODE=^PSD(58.81,PSDA,0)
SET PSDPN=$SELECT($PIECE(NODE,"^",17)]"":$PIECE(NODE,"^",17),1:"UNKNOWN")
+5 SET NAOU=+$PIECE(NODE,"^",18)
if '$DATA(NAOU(NAOU))
QUIT
SET NAOUN=$SELECT($PIECE($GET(^PSD(58.8,NAOU,0)),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_NAOU)
IF NAOUN'="UNKNOWN"
+6 if '$DATA(NAOU(NAOU))
QUIT
+7 SET DRUG=+$PIECE(NODE,"^",5)
SET DRUGN=$SELECT($PIECE($GET(^PSDRUG(DRUG,0)),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_DRUG)
+8 SET NODE7=^PSD(58.81,PSDA,7)
SET QTY=+$PIECE(NODE7,"^",7)
SET NAOUT=$PIECE(NODE7,"^",3)
SET TRFD=+$PIECE(NODE7,"^")
SET NURSF=+$PIECE(NODE7,"^",2)
+9 SET NAOUTN=$PIECE($GET(^PSD(58.8,NAOUT,0)),"^")
IF TRFD
SET Y=TRFD
XECUTE ^DD("DD")
SET TRFD=Y
+10 IF NURSF
SET NURSF=$PIECE($GET(^VA(200,NURSF,0)),"^")
SET NURSF=$PIECE(NURSF,",")_","_$EXTRACT($PIECE(NURSF,",",2))
+11 SET ^TMP("PSDNBT",$JOB,DRUGN,PSDPN,PSDA)=NAOUTN_"^"_NAOUN_"^"_QTY_"^"_TRFD_"^"_NURSF
End DoDot:1
PRINT ;print
+1 DO NOW^%DTC
SET Y=X
XECUTE ^DD("DD")
SET RPDT=Y
+2 SET (PG,PSDOUT)=0
+3 KILL LN
SET $PIECE(LN,"-",132)=""
IF '$DATA(^TMP("PSDNBT",$JOB))
DO HDR
WRITE !!,?30,"**** NO GREEN SHEETS TRANSFERRED BETWEEN NAOUs PENDING RECEIPT ****",!
GOTO DONE
+4 DO HDR
SET DRUG=""
FOR
SET DRUG=$ORDER(^TMP("PSDNBT",$JOB,DRUG))
if DRUG=""!(PSDOUT)
QUIT
WRITE !!,?5,"= > ",DRUG,!
Begin DoDot:1
+5 SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDNBT",$JOB,DRUG,NUM))
if NUM=""!(PSDOUT)
QUIT
FOR PSD=0:0
SET PSD=$ORDER(^TMP("PSDNBT",$JOB,DRUG,NUM,PSD))
if 'PSD!(PSDOUT)
QUIT
Begin DoDot:2
+6 IF $Y+5>IOSL
DO HDR
if PSDOUT
QUIT
WRITE !!,?5,"=> ",DRUG,!
+7 SET NODE=^TMP("PSDNBT",$JOB,DRUG,NUM,PSD)
WRITE !,NUM,?12,$PIECE(NODE,"^",4),?38,$EXTRACT($PIECE(NODE,"^",2),1,25),?60,$JUSTIFY($PIECE(NODE,"^",3),6),?80,$PIECE(NODE,"^",5),?100,$EXTRACT($PIECE(NODE,"^"),1,30)
End DoDot:2
End DoDot:1
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 ;
+1 KILL %,%DT,%H,%I,%ZIS,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DRUG,DRUGN,DUOUT,IO("Q"),JJ,LN,NAOU,NAOUN,NAOUT,NAOUTN,NODE,NODE7,NUM,NURSF
+2 KILL OK,POP,PG,PHARM,PHARMN,POP,PSD,PSDA,PSDDT,PSDOUT,PSDPN,PSDS,PSDSN,PSDST,QTY,RPDT,TRFD,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
+3 KILL ^TMP("PSDNBT",$JOB),^TMP("PSDFNDT",$JOB)
DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
+4 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 !,?25,"GREEN SHEETS TRANSFERRED BETWEEN NAOUs PENDING RECEIPT",?115,"Page: ",PG,!,?40,RPDT,!
+3 WRITE !!,?5,"=> DRUG",!,?16,"DATE",?38,"NAOU",?82,"NURSE",?104,"NAOU"
+4 WRITE !,"DISP #",?11,"TRANSFERRED FROM",?32,"TRANSFERRED FROM",?62,"QUANTITY",?80,"TRANSFERRING",?100,"TRANSFERRED TO",!,LN
+5 QUIT