PSDEVOR ;BIR/BJW-Print Edit/Canc Ver Orders Report ; 9 Feb 98
;;3.0; CONTROLLED SUBSTANCES ;**8**;13 Feb 97
;**Y2K compliance**,"P" added to date input string
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
I '$D(^XUSEC("PSJ RPHARM",DUZ)) W !!,"Contact your Pharmacy Coordinator for access to print the Edit Verified",!,"Orders data. PSJ RPHARM security key required.",!! Q
ASKD ;ask disp location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) CHKD
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)"
S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=PSDSN
D ^DIC K DIC G:Y<0 END
S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
CHKD I '$O(^PSD(58.8,PSDS,1,0)) W !!,"There are no CS stocked drugs for your dispensing vault.",!! G END
DATE W ! K %DT S %DT="AEPX",%DT("A")="Start with Date: " D ^%DT I Y<0 G END
S PSDSD=Y D D^DIQ S PSDATE=Y,%DT("A")="End with Date: " D ^%DT I Y<0 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
W !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
DEV ;sel device
S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
W ! 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"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDEVOR",ZTDESC="CS PHARM Edit/Canc Ver Ord" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;entry for compile
K ^TMP("PSDEVOR",$J) S PSD1=12.99,PSD2=14.99
F PSD=PSDSD:0 S PSD=$O(^PSD(58.81,"ACT",PSD)) Q:'PSD!(PSD>PSDED) F PSDR=0:0 S PSDR=$O(^PSD(58.81,"ACT",PSD,PSDS,PSDR)) Q:'PSDR D
.F PSDTYP=PSD1:0 S PSDTYP=$O(^PSD(58.81,"ACT",PSD,PSDS,PSDR,PSDTYP)) Q:'PSDTYP!(PSDTYP>PSD2) F PSDA=0:0 S PSDA=$O(^PSD(58.81,"ACT",PSD,PSDS,PSDR,PSDTYP,PSDA)) Q:'PSDA D
..Q:'$D(^PSD(58.81,PSDA,0)) S NODE=^(0),PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN"),QTY=$P(NODE,"^",6)
..S PSDRN=$S($P($G(^PSDRUG(PSDR,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSDR_" NAME MISSING")
..I $D(^PSD(58.81,PSDA,4)),PSDTYP=14 S NQTY=$P(^(4),"^",3),MFG=+$P(^(4),"^",5),PHARM=$P(^(4),"^",2),PHARM=$P($G(^VA(200,+PHARM,0)),"^"),PHARM=$P(PHARM,",")_","_$E($P(PHARM,",",2)),ACT="EDIT"
..I $D(^PSD(58.81,PSDA,5)),PSDTYP=13 S PHARM=$P(^(5),"^",2),PHARM=$P($G(^VA(200,+PHARM,0)),"^"),PHARM=$P(PHARM,",")_","_$E($P(PHARM,",",2)),NQTY=0,MFG=0,ACT="CANC"
..S ^TMP("PSDEVOR",$J,PSD,PSDPN,PSDTYP)=PSDRN_"^"_ACT_"^"_PHARM_"^"_QTY_"^"_NQTY_"^"_MFG
PRINT ;prints data
K LN S (PG,PSDOUT)=0,$P(LN,"-",132)="" D HDR
I '$D(^TMP("PSDEVOR",$J)) W !!,?15,"**** NO VERIFIED ORDERS EDITED OR CANCELLED ****",!! G DONE
F PSD=0:0 S PSD=$O(^TMP("PSDEVOR",$J,PSD)) Q:'PSD!(PSDOUT) S NUM="" F S NUM=$O(^TMP("PSDEVOR",$J,PSD,NUM)) Q:NUM=""!(PSDOUT) F TYPE=0:0 S TYPE=$O(^TMP("PSDEVOR",$J,PSD,NUM,TYPE)) Q:'TYPE!(PSDOUT) D
.S DATE=$E(PSD,4,5)_"/"_$E(PSD,6,7)_"/"_$E(PSD,2,3),NODE=^TMP("PSDEVOR",$J,PSD,NUM,TYPE)
.S MFG=$P(NODE,"^",6)
.D:$Y+4>IOSL HDR Q:PSDOUT
.W !,NUM,?10,$P(NODE,"^"),?53,$P(NODE,"^",2),?60,DATE,?70,$P(NODE,"^",4),?78,$P(NODE,"^",5),?90,$S(MFG:"FIELDS EDITED",1:"NOT EDITED"),?110,$P(NODE,"^",3)
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,ACT,C,DA,DATE,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LN,MFG,NODE,NQTY,NUM
K PG,PHARM,POP,PSD,PSD1,PSD2,PSDA,PSDATE,PSDED,PSDEV,PSDOUT,PSDPN,PSDR,PSDRN,PSDS,PSDSD,PSDSN,PSDTYP,QTY,TYPE,X,Y
K ^TMP("PSDEVOR",$J),ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
SAVE S (ZTSAVE("PSDS"),ZTSAVE("PSDSN"))=""
S (ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"))=""
Q
HDR ;header
I $E(IOST,1,2)="C-",PG 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 !,?20,"Edited or Verified Orders for ",PSDSN,?115,"Page: ",PG,!,?20,"Date: ",$P(PSDATE,"^")," to ",$P(PSDATE,"^",2),!!
W ?70,"ORIG",?78,"NEW",!
W "DISP #",?10,"DRUG",?52,"ACTION",?62,"DATE",?70,"QTY",?78,"QTY",?86,"MFG/LOT #/EXP.DATE",?110,"PHARMACIST",!,LN,!!
Q
PSDEVOR ;BIR/BJW-Print Edit/Canc Ver Orders Report ; 9 Feb 98
+1 ;;3.0; CONTROLLED SUBSTANCES ;**8**;13 Feb 97
+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))
WRITE !!,"Contact your Pharmacy Coordinator for access to print the Edit Verified",!,"Orders data. PSJ RPHARM security key required.",!!
QUIT
ASKD ;ask disp location
+1 SET PSDS=$PIECE(PSDSITE,U,3)
SET PSDSN=$PIECE(PSDSITE,U,4)
+2 IF $PIECE(PSDSITE,U,5)
GOTO CHKD
+3 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)"
+4 SET DIC("A")="Select Primary Dispensing Site: "
SET DIC("B")=PSDSN
+5 DO ^DIC
KILL DIC
IF Y<0
GOTO END
+6 SET PSDS=+Y
SET PSDSN=$PIECE(Y,"^",2)
SET $PIECE(PSDSITE,U,3)=+Y
SET $PIECE(PSDSITE,U,4)=PSDSN
CHKD IF '$ORDER(^PSD(58.8,PSDS,1,0))
WRITE !!,"There are no CS stocked drugs for your dispensing vault.",!!
GOTO END
DATE WRITE !
KILL %DT
SET %DT="AEPX"
SET %DT("A")="Start with Date: "
DO ^%DT
IF Y<0
GOTO END
+1 SET PSDSD=Y
DO D^DIQ
SET PSDATE=Y
SET %DT("A")="End with Date: "
DO ^%DT
IF Y<0
GOTO END
+2 IF Y<PSDSD
WRITE !!,"The ending date of the range must be later than the starting date."
GOTO DATE
+3 SET PSDED=Y
DO D^DIQ
SET PSDATE=PSDATE_"^"_Y
SET PSDSD=PSDSD-.0001
SET PSDED=PSDED+.9999
+4 WRITE !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
DEV ;sel device
+1 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
+2 WRITE !
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
+3 IF $DATA(IO("Q"))
KILL IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDEVOR"
SET ZTDESC="CS PHARM Edit/Canc Ver Ord"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+4 USE IO
START ;entry for compile
+1 KILL ^TMP("PSDEVOR",$JOB)
SET PSD1=12.99
SET PSD2=14.99
+2 FOR PSD=PSDSD:0
SET PSD=$ORDER(^PSD(58.81,"ACT",PSD))
IF 'PSD!(PSD>PSDED)
QUIT
FOR PSDR=0:0
SET PSDR=$ORDER(^PSD(58.81,"ACT",PSD,PSDS,PSDR))
IF 'PSDR
QUIT
Begin DoDot:1
+3 FOR PSDTYP=PSD1:0
SET PSDTYP=$ORDER(^PSD(58.81,"ACT",PSD,PSDS,PSDR,PSDTYP))
IF 'PSDTYP!(PSDTYP>PSD2)
QUIT
FOR PSDA=0:0
SET PSDA=$ORDER(^PSD(58.81,"ACT",PSD,PSDS,PSDR,PSDTYP,PSDA))
IF 'PSDA
QUIT
Begin DoDot:2
+4 IF '$DATA(^PSD(58.81,PSDA,0))
QUIT
SET NODE=^(0)
SET PSDPN=$SELECT($PIECE(NODE,"^",17)]"":$PIECE(NODE,"^",17),1:"UNKNOWN")
SET QTY=$PIECE(NODE,"^",6)
+5 SET PSDRN=$SELECT($PIECE($GET(^PSDRUG(PSDR,0)),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_PSDR_" NAME MISSING")
+6 IF $DATA(^PSD(58.81,PSDA,4))
IF PSDTYP=14
SET NQTY=$PIECE(^(4),"^",3)
SET MFG=+$PIECE(^(4),"^",5)
SET PHARM=$PIECE(^(4),"^",2)
SET PHARM=$PIECE($GET(^VA(200,+PHARM,0)),"^")
SET PHARM=$PIECE(PHARM,",")_","_$EXTRACT($PIECE(PHARM,",",2))
SET ACT="EDIT"
+7 IF $DATA(^PSD(58.81,PSDA,5))
IF PSDTYP=13
SET PHARM=$PIECE(^(5),"^",2)
SET PHARM=$PIECE($GET(^VA(200,+PHARM,0)),"^")
SET PHARM=$PIECE(PHARM,",")_","_$EXTRACT($PIECE(PHARM,",",2))
SET NQTY=0
SET MFG=0
SET ACT="CANC"
+8 SET ^TMP("PSDEVOR",$JOB,PSD,PSDPN,PSDTYP)=PSDRN_"^"_ACT_"^"_PHARM_"^"_QTY_"^"_NQTY_"^"_MFG
End DoDot:2
End DoDot:1
PRINT ;prints data
+1 KILL LN
SET (PG,PSDOUT)=0
SET $PIECE(LN,"-",132)=""
DO HDR
+2 IF '$DATA(^TMP("PSDEVOR",$JOB))
WRITE !!,?15,"**** NO VERIFIED ORDERS EDITED OR CANCELLED ****",!!
GOTO DONE
+3 FOR PSD=0:0
SET PSD=$ORDER(^TMP("PSDEVOR",$JOB,PSD))
IF 'PSD!(PSDOUT)
QUIT
SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDEVOR",$JOB,PSD,NUM))
IF NUM=""!(PSDOUT)
QUIT
FOR TYPE=0:0
SET TYPE=$ORDER(^TMP("PSDEVOR",$JOB,PSD,NUM,TYPE))
IF 'TYPE!(PSDOUT)
QUIT
Begin DoDot:1
+4 SET DATE=$EXTRACT(PSD,4,5)_"/"_$EXTRACT(PSD,6,7)_"/"_$EXTRACT(PSD,2,3)
SET NODE=^TMP("PSDEVOR",$JOB,PSD,NUM,TYPE)
+5 SET MFG=$PIECE(NODE,"^",6)
+6 IF $Y+4>IOSL
DO HDR
IF PSDOUT
QUIT
+7 WRITE !,NUM,?10,$PIECE(NODE,"^"),?53,$PIECE(NODE,"^",2),?60,DATE,?70,$PIECE(NODE,"^",4),?78,$PIECE(NODE,"^",5),?90,$SELECT(MFG:"FIELDS EDITED",1:"NOT EDITED"),?110,$PIECE(NODE,"^",3)
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,ACT,C,DA,DATE,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LN,MFG,NODE,NQTY,NUM
+2 KILL PG,PHARM,POP,PSD,PSD1,PSD2,PSDA,PSDATE,PSDED,PSDEV,PSDOUT,PSDPN,PSDR,PSDRN,PSDS,PSDSD,PSDSN,PSDTYP,QTY,TYPE,X,Y
+3 KILL ^TMP("PSDEVOR",$JOB),ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+4 DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+5 QUIT
SAVE SET (ZTSAVE("PSDS"),ZTSAVE("PSDSN"))=""
+1 SET (ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"))=""
+2 QUIT
HDR ;header
+1 IF $EXTRACT(IOST,1,2)="C-"
IF PG
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 !,?20,"Edited or Verified Orders for ",PSDSN,?115,"Page: ",PG,!,?20,"Date: ",$PIECE(PSDATE,"^")," to ",$PIECE(PSDATE,"^",2),!!
+3 WRITE ?70,"ORIG",?78,"NEW",!
+4 WRITE "DISP #",?10,"DRUG",?52,"ACTION",?62,"DATE",?70,"QTY",?78,"QTY",?86,"MFG/LOT #/EXP.DATE",?110,"PHARMACIST",!,LN,!!
+5 QUIT