PSDNTR ;BIR/BJW-CS Transfer Between NAOUs Report ; 11 Feb 98
;;3.0; CONTROLLED SUBSTANCES ;**8,71**;13 Feb 97;Build 29
;**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))) W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to print",!,?12,"CS reports. PSJ RPHARM or PSD TECH ADV security key required.",! Q
W !!,"CS Transfer Green Sheets Between NAOUs 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
ASKN ;ask NAOU(s)
W !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!
D NOW^%DTC S PSDT=X 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 NAOU(+Y)=""
I '$D(NAOU)&(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 NAOU(PSD)=""
DEV ;dev & 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^PSDNTR",ZTDESC="CS Transfer Between NAOUs Report" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;compile data
K ^TMP("PSDNTR",$J) S PSDOUT=0
F PSD=PSDSD:0 S PSD=$O(^PSD(58.81,"ATRN",PSD)) Q:'PSD!(PSD>PSDED) F PSDA=0:0 S PSDA=$O(^PSD(58.81,"ATRN",PSD,PSDA)) Q:'PSDA I $D(^PSD(58.81,PSDA,0)),$D(^(7)) D SET
PRINT ;print transfer between naous by date
S (PG,PSDOUT)=0
K LN S $P(LN,"-",132)="" D NOW^%DTC S Y=+$E(%,1,12) X ^DD("DD") S RPDT=Y
I '$D(^TMP("PSDNTR",$J)) D HDR W !!,?45,"**** NO TRANSFER BETWEEN NAOUs DATA FOR THIS REPORT ****" G DONE
D HDR
S PSD="" F S PSD=$O(^TMP("PSDNTR",$J,PSD)) Q:PSD=""!(PSDOUT) W !!,?5,"=> ",PSD,! S NUM="" F S NUM=$O(^TMP("PSDNTR",$J,PSD,NUM)) Q:NUM=""!(PSDOUT) F PSDA=0:0 S PSDA=$O(^TMP("PSDNTR",$J,PSD,NUM,PSDA)) Q:'PSDA!(PSDOUT) D
.D:$Y+5>IOSL HDR Q:PSDOUT
.S NODE=^TMP("PSDNTR",$J,PSD,NUM,PSDA) W !,NUM,?12,$P(NODE,"^"),?38,$E($P(NODE,"^",4),1,30),?60,$J($P(NODE,"^",3),6),?80,$P(NODE,"^",2),?100,$E($P(NODE,"^",5),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,LN,NAOU,NAOUN,NAOUT,NAOUTN,NODE,NODE7,NUM,OK
K PG,POP,PSD,PSDA,PSDATE,PSDDT,PSDED,PSDOUT,PSDPN,PSDSD,PSDT,QTY,RPDT,TRFD,TRTD,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDNTR",$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 !,?35,"CS TRANSFER GREEN SHEETS BETWEEN NAOUs REPORT",?120,"Page: ",PG
W !,?35,"FOR PERIOD ",$P(PSDATE,"^")," TO ",$P(PSDATE,"^",2)
W !,?40,"PRINTED ",RPDT,!!,?5,"=> DRUG",!
W ?16,"DATE",?36,"NAOU",?86,"DATE",?104,"NAOU",!
W "DISP #",?11,"TRANSFERRED FROM",?32,"TRANSFERRED FROM",?62,"QUANTITY",?82,"TRANSFERRED IN",?100,"TRANSFERRED IN",!,LN,!
Q
SAVE S (ZTSAVE("PSDSITE"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"))=""
S:$D(NAOU) ZTSAVE("NAOU(")=""
Q
SET ;set data for printing
S NODE=^PSD(58.81,PSDA,0),DRUG=+$P(NODE,"^",5),NAOU=+$P(NODE,"^",18) Q:'$D(NAOU(NAOU))
S PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN")
S DRUGN=$S($D(^PSDRUG(DRUG,0)):$P(^(0),"^"),1:"DRUG NAME MISSING")
S NAOUN=$S($D(^PSD(58.8,NAOU,0)):$P(^(0),"^"),1:"NAOU NAME MISSING")
S NODE7=^PSD(58.81,PSDA,7),TRFD=+$P(NODE7,"^"),TRTD=+$P(NODE7,"^",4)
Q:'TRTD!('TRFD) S Y=TRFD X ^DD("DD") S TRFD=Y
S Y=TRTD X ^DD("DD") S TRTD=Y
S NAOUT=+$P(NODE7,"^",3),NAOUTN=$S($D(^PSD(58.8,NAOUT,0)):$P(^(0),"^"),1:"NAOU NAME MISSING")
S QTY=+$P(NODE7,"^",7)
S ^TMP("PSDNTR",$J,DRUGN,PSDPN,PSDA)=TRFD_"^"_TRTD_"^"_QTY_"^"_NAOUN_"^"_NAOUTN
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDNTR 4481 printed Nov 22, 2024@16:57:17 Page 2
PSDNTR ;BIR/BJW-CS Transfer Between NAOUs Report ; 11 Feb 98
+1 ;;3.0; CONTROLLED SUBSTANCES ;**8,71**;13 Feb 97;Build 29
+2 ;**Y2K compliance**,"P" added to date input string
+3 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
QUIT
+4 IF '$DATA(^XUSEC("PSJ RPHARM",DUZ))&('$DATA(^XUSEC("PSD TECH ADV",DUZ)))
WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to print",!,?12,"CS reports. PSJ RPHARM or PSD TECH ADV security key required.",!
QUIT
+5 WRITE !!,"CS Transfer Green Sheets Between NAOUs 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
ASKN ;ask NAOU(s)
+1 WRITE !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!
+2 DO NOW^%DTC
SET PSDT=X
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 NAOU(+Y)=""
+4 IF '$DATA(NAOU)&(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 NAOU(PSD)=""
DEV ;dev & 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^PSDNTR"
SET ZTDESC="CS Transfer Between NAOUs Report"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+4 USE IO
START ;compile data
+1 KILL ^TMP("PSDNTR",$JOB)
SET PSDOUT=0
+2 FOR PSD=PSDSD:0
SET PSD=$ORDER(^PSD(58.81,"ATRN",PSD))
if 'PSD!(PSD>PSDED)
QUIT
FOR PSDA=0:0
SET PSDA=$ORDER(^PSD(58.81,"ATRN",PSD,PSDA))
if 'PSDA
QUIT
IF $DATA(^PSD(58.81,PSDA,0))
IF $DATA(^(7))
DO SET
PRINT ;print transfer between naous by date
+1 SET (PG,PSDOUT)=0
+2 KILL LN
SET $PIECE(LN,"-",132)=""
DO NOW^%DTC
SET Y=+$EXTRACT(%,1,12)
XECUTE ^DD("DD")
SET RPDT=Y
+3 IF '$DATA(^TMP("PSDNTR",$JOB))
DO HDR
WRITE !!,?45,"**** NO TRANSFER BETWEEN NAOUs DATA FOR THIS REPORT ****"
GOTO DONE
+4 DO HDR
+5 SET PSD=""
FOR
SET PSD=$ORDER(^TMP("PSDNTR",$JOB,PSD))
if PSD=""!(PSDOUT)
QUIT
WRITE !!,?5,"=> ",PSD,!
SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDNTR",$JOB,PSD,NUM))
if NUM=""!(PSDOUT)
QUIT
FOR PSDA=0:0
SET PSDA=$ORDER(^TMP("PSDNTR",$JOB,PSD,NUM,PSDA))
if 'PSDA!(PSDOUT)
QUIT
Begin DoDot:1
+6 if $Y+5>IOSL
DO HDR
if PSDOUT
QUIT
+7 SET NODE=^TMP("PSDNTR",$JOB,PSD,NUM,PSDA)
WRITE !,NUM,?12,$PIECE(NODE,"^"),?38,$EXTRACT($PIECE(NODE,"^",4),1,30),?60,$JUSTIFY($PIECE(NODE,"^",3),6),?80,$PIECE(NODE,"^",2),?100,$EXTRACT($PIECE(NODE,"^",5),1,30)
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,LN,NAOU,NAOUN,NAOUT,NAOUTN,NODE,NODE7,NUM,OK
+2 KILL PG,POP,PSD,PSDA,PSDATE,PSDDT,PSDED,PSDOUT,PSDPN,PSDSD,PSDT,QTY,RPDT,TRFD,TRTD,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
+3 KILL ^TMP("PSDNTR",$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 !,?35,"CS TRANSFER GREEN SHEETS BETWEEN NAOUs REPORT",?120,"Page: ",PG
+3 WRITE !,?35,"FOR PERIOD ",$PIECE(PSDATE,"^")," TO ",$PIECE(PSDATE,"^",2)
+4 WRITE !,?40,"PRINTED ",RPDT,!!,?5,"=> DRUG",!
+5 WRITE ?16,"DATE",?36,"NAOU",?86,"DATE",?104,"NAOU",!
+6 WRITE "DISP #",?11,"TRANSFERRED FROM",?32,"TRANSFERRED FROM",?62,"QUANTITY",?82,"TRANSFERRED IN",?100,"TRANSFERRED IN",!,LN,!
+7 QUIT
SAVE SET (ZTSAVE("PSDSITE"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"))=""
+1 if $DATA(NAOU)
SET ZTSAVE("NAOU(")=""
+2 QUIT
SET ;set data for printing
+1 SET NODE=^PSD(58.81,PSDA,0)
SET DRUG=+$PIECE(NODE,"^",5)
SET NAOU=+$PIECE(NODE,"^",18)
if '$DATA(NAOU(NAOU))
QUIT
+2 SET PSDPN=$SELECT($PIECE(NODE,"^",17)]"":$PIECE(NODE,"^",17),1:"UNKNOWN")
+3 SET DRUGN=$SELECT($DATA(^PSDRUG(DRUG,0)):$PIECE(^(0),"^"),1:"DRUG NAME MISSING")
+4 SET NAOUN=$SELECT($DATA(^PSD(58.8,NAOU,0)):$PIECE(^(0),"^"),1:"NAOU NAME MISSING")
+5 SET NODE7=^PSD(58.81,PSDA,7)
SET TRFD=+$PIECE(NODE7,"^")
SET TRTD=+$PIECE(NODE7,"^",4)
+6 if 'TRTD!('TRFD)
QUIT
SET Y=TRFD
XECUTE ^DD("DD")
SET TRFD=Y
+7 SET Y=TRTD
XECUTE ^DD("DD")
SET TRTD=Y
+8 SET NAOUT=+$PIECE(NODE7,"^",3)
SET NAOUTN=$SELECT($DATA(^PSD(58.8,NAOUT,0)):$PIECE(^(0),"^"),1:"NAOU NAME MISSING")
+9 SET QTY=+$PIECE(NODE7,"^",7)
+10 SET ^TMP("PSDNTR",$JOB,DRUGN,PSDPN,PSDA)=TRFD_"^"_TRTD_"^"_QTY_"^"_NAOUN_"^"_NAOUTN
+11 QUIT