PSDOPTN ;BIR/LTL - Review OP Transactions for a Drug (cont.) ; 24 Jan 95
;;3.0; CONTROLLED SUBSTANCES ;**18,55**;13 Feb 97
;
;References to ^PSD(58.8, covered by DBIA2711
;References to DD(58.81 and ^PSD(58.81 are covered by DBIA2808
;References to ^PSDRUG( are covered by DBIA221
;References to ^PSRX( are covered by DBIA986
S DIR(0)="DA^2910501::AEPT"
S DIR("A")="Beginning date@time filled (not posted): ",DIR("?")="I will list Outpatient transactions for your selected drug(s) within your selected date@time range. Please don't enter a date@time in the future" W ! D ^DIR G:Y<1 END
S (PSDT,PSDTB)=Y,PSDTB(2)=Y(0)
S DIR(0)="DA^"_PSDT_"::AET"
S DIR("A")="Ending date@time filled (not posted): "
S DIR("?")=$G(DIR("?"))_" or before "_$G(PSDTB(2))
W ! D ^DIR K DIR G:Y<1 END S PSDTB(1)=Y,PSDTB(3)=Y(0)
S:'$P(PSDTB(1),".",2) PSDTB(1)=PSDTB(1)+.999999
S Y=$P($G(^PSD(58.8,+PSDLOC,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
DEV ;device
K IO("Q") N %ZIS,IOP,POP S %ZIS="Q",%ZIS("B")=PSDEV W ! D ^%ZIS I POP W !,"NO DEVICE SELECTED OR OUTPUT PRINTED!" Q
I $D(IO("Q")) N ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDOPTN",ZTDESC="Drug OP transaction review" D SAVE D ^%ZTLOAD,HOME^%ZIS S PSDOUT=1 G END
START ;compiles
U IO N PSDR,PG S (PG,PSDOUT)=0 K LN D HEADER S PSDT=PSDT-1
;loop thru Prescription file by date filled
F S PSDT=$O(^PSRX("AD",PSDT)) Q:'PSDT!(PSDT>PSDTB(1)) W:$E(IOST)="C" "." S PSDT(1)=0 D
.F S PSDT(1)=$O(^PSRX("AD",PSDT,PSDT(1))) Q:'PSDT(1) D
..S PSDT(5)=$G(^PSRX(PSDT(1),0))
..S PSDT(2)=$P($G(^PSDRUG(+$P(PSDT(5),U,6),0)),U) Q:PSDT(2)']""
..Q:'$D(^TMP("PSD",$J,PSDT(2))) S PSDT(4)=""
..F S PSDT(4)=$O(^PSRX("AD",PSDT,PSDT(1),PSDT(4))) Q:PSDT(4)="" D
...;Returned to stock?
...Q:$S('PSDT(4):$P($G(^PSRX(PSDT(1),2)),U,15),1:$P($G(^PSRX(PSDT(1),1,PSDT(4),0)),U,16))
...;posted to the vault?
...S PSDT(3)=0
...F S PSDT(3)=$O(^PSD(58.81,"AOP",PSDT(1),PSDT(3))) Q:'PSDT(3)!($S('PSDT(4)&('$P($G(^PSD(58.81,+PSDT(3),6)),U,2)):1,PSDT(4)=$P($G(^(6)),U,2):1,1:0))
...Q:PSDT(3)
...;suspended & printed
...S (PSDT(3),PSDT(8))=0
...I PSDT>DT D Q:'PSDT(8)
....F S PSDT(3)=$O(^PSRX(PSDT(1),"L",PSDT(3))) Q:'PSDT(3) S:$P($G(^PSRX(PSDT(1),"L",PSDT(3),0)),U,2)=PSDT(4) PSDT(8)=1
...;quantity
...S PSDT(6)=$S('PSDT(4):$P(PSDT(5),U,7),1:$P($G(^PSRX(PSDT(1),1,PSDT(4),0)),U,4))
...S DFN=$P(PSDT(5),U,2) N C S Y=DFN,C=$P(^DD(58.81,73,0),U,2) D Y^DIQ
...S PSDT(7)=Y D PID^VADPT6 S PSDT(7)=PSDT(7)_" ("_VA("BID")_")"
...S:$P(PSDT(5),U)]"" ^TMP("PSDO",$J,PSDT(2),$P(PSDT(5),U),PSDT(4))=PSDT(6)_U_PSDT_U_PSDT(7)
I '$D(^TMP("PSDO",$J)) W !!,"Nothing to Report.",!! G END
F S PSDT=$O(^TMP("PSDO",$J,PSDT)) Q:PSDT']""!PSDOUT D Q:PSDOUT
.D:$Y+5>IOSL HEADER Q:PSDOUT W !!,"Drug => ",PSDT S PSDT(1)=0
.F S PSDT(1)=$O(^TMP("PSDO",$J,PSDT,PSDT(1))) Q:'PSDT(1)!PSDOUT D Q:PSDOUT
..S PSDT(2)=""
..F S PSDT(2)=$O(^TMP("PSDO",$J,PSDT,PSDT(1),PSDT(2))) Q:PSDT(2)=""!PSDOUT D Q:PSDOUT
...I $Y+4>IOSL D HEADER Q:PSDOUT W !!,PSDT," (continued)"
...W !!,PSDT(1)," (",PSDT(2),")"
...S PSDT(3)=$G(^TMP("PSDO",$J,PSDT,PSDT(1),PSDT(2)))
...W ?9,$J($P(PSDT(3),U),4) S Y=$P(PSDT(3),U,2) X ^DD("DD") W ?20,Y
...W ?40,$P(PSDT(3),U,3)
END W:$E(IOST)'="C" @IOF
I $E(IOST)="C",'PSDOUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu." W ! D ^DIR
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
D KVAR^VADPT K IO("Q"),VA("PID"),VA("BID"),^TMP("PSDO",$J)
Q
I $$S^%ZTLOAD W !!,"Task #",$G(ZTSK),", ",$G(ZTDESC)," was stopped by ",$P($G(^VA(200,+$G(DUZ),0)),U),"." S PSDOUT=1
W:$Y @IOF S $P(LN,"-",81)="",PG=PG+1 W !,"Outpatient Activity from ",PSDTB(2)," to ",PSDTB(3),?70,"PAGE: ",PG,!,LN,!,"Rx#",?10,"QTY",?20,"Fill Date",?40,"Patient",!,LN
Q
SAVE ;
S ZTSAVE("^TMP(""PSD"",$J,")=""
S (ZTSAVE("PSDT"),ZTSAVE("PSDLOC"),ZTSAVE("PSDTB"),ZTSAVE("PSDTB("))=""
Q
PSDOPTN ;BIR/LTL - Review OP Transactions for a Drug (cont.) ; 24 Jan 95
+1 ;;3.0; CONTROLLED SUBSTANCES ;**18,55**;13 Feb 97
+2 ;
+3 ;References to ^PSD(58.8, covered by DBIA2711
+4 ;References to DD(58.81 and ^PSD(58.81 are covered by DBIA2808
+5 ;References to ^PSDRUG( are covered by DBIA221
+6 ;References to ^PSRX( are covered by DBIA986
+7 SET DIR(0)="DA^2910501::AEPT"
+8 SET DIR("A")="Beginning date@time filled (not posted): "
SET DIR("?")="I will list Outpatient transactions for your selected drug(s) within your selected date@time range. Please don't enter a date@time in the future"
WRITE !
DO ^DIR
IF Y<1
GOTO END
+9 SET (PSDT,PSDTB)=Y
SET PSDTB(2)=Y(0)
+10 SET DIR(0)="DA^"_PSDT_"::AET"
+11 SET DIR("A")="Ending date@time filled (not posted): "
+12 SET DIR("?")=$GET(DIR("?"))_" or before "_$GET(PSDTB(2))
+13 WRITE !
DO ^DIR
KILL DIR
IF Y<1
GOTO END
SET PSDTB(1)=Y
SET PSDTB(3)=Y(0)
+14 IF '$PIECE(PSDTB(1),".",2)
SET PSDTB(1)=PSDTB(1)+.999999
+15 SET Y=$PIECE($GET(^PSD(58.8,+PSDLOC,2)),"^",9)
SET C=$PIECE(^DD(58.8,24,0),"^",2)
DO Y^DIQ
SET PSDEV=Y
DEV ;device
+1 KILL IO("Q")
NEW %ZIS,IOP,POP
SET %ZIS="Q"
SET %ZIS("B")=PSDEV
WRITE !
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR OUTPUT PRINTED!"
QUIT
+2 IF $DATA(IO("Q"))
NEW ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDOPTN"
SET ZTDESC="Drug OP transaction review"
DO SAVE
DO ^%ZTLOAD
DO HOME^%ZIS
SET PSDOUT=1
GOTO END
START ;compiles
+1 USE IO
NEW PSDR,PG
SET (PG,PSDOUT)=0
KILL LN
DO HEADER
SET PSDT=PSDT-1
+2 ;loop thru Prescription file by date filled
+3 FOR
SET PSDT=$ORDER(^PSRX("AD",PSDT))
IF 'PSDT!(PSDT>PSDTB(1))
QUIT
IF $EXTRACT(IOST)="C"
WRITE "."
SET PSDT(1)=0
Begin DoDot:1
+4 FOR
SET PSDT(1)=$ORDER(^PSRX("AD",PSDT,PSDT(1)))
IF 'PSDT(1)
QUIT
Begin DoDot:2
+5 SET PSDT(5)=$GET(^PSRX(PSDT(1),0))
+6 SET PSDT(2)=$PIECE($GET(^PSDRUG(+$PIECE(PSDT(5),U,6),0)),U)
IF PSDT(2)']""
QUIT
+7 IF '$DATA(^TMP("PSD",$JOB,PSDT(2)))
QUIT
SET PSDT(4)=""
+8 FOR
SET PSDT(4)=$ORDER(^PSRX("AD",PSDT,PSDT(1),PSDT(4)))
IF PSDT(4)=""
QUIT
Begin DoDot:3
+9 ;Returned to stock?
+10 IF $SELECT('PSDT(4)
QUIT
+11 ;posted to the vault?
+12 SET PSDT(3)=0
+13 FOR
SET PSDT(3)=$ORDER(^PSD(58.81,"AOP",PSDT(1),PSDT(3)))
IF 'PSDT(3)!($SELECT('PSDT(4)&('$PIECE($GET(^PSD(58.81,+PSDT(3),6)),U,2))
QUIT
+14 IF PSDT(3)
QUIT
+15 ;suspended & printed
+16 SET (PSDT(3),PSDT(8))=0
+17 IF PSDT>DT
Begin DoDot:4
+18 FOR
SET PSDT(3)=$ORDER(^PSRX(PSDT(1),"L",PSDT(3)))
IF 'PSDT(3)
QUIT
IF $PIECE($GET(^PSRX(PSDT(1),"L",PSDT(3),0)),U,2)=PSDT(4)
SET PSDT(8)=1
End DoDot:4
IF 'PSDT(8)
QUIT
+19 ;quantity
+20 SET PSDT(6)=$SELECT('PSDT(4):$PIECE(PSDT(5),U,7),1:$PIECE($GET(^PSRX(PSDT(1),1,PSDT(4),0)),U,4))
+21 SET DFN=$PIECE(PSDT(5),U,2)
NEW C
SET Y=DFN
SET C=$PIECE(^DD(58.81,73,0),U,2)
DO Y^DIQ
+22 SET PSDT(7)=Y
DO PID^VADPT6
SET PSDT(7)=PSDT(7)_" ("_VA("BID")_")"
+23 IF $PIECE(PSDT(5),U)]""
SET ^TMP("PSDO",$JOB,PSDT(2),$PIECE(PSDT(5),U),PSDT(4))=PSDT(6)_U_PSDT_U_PSDT(7)
End DoDot:3
End DoDot:2
End DoDot:1
+24 IF '$DATA(^TMP("PSDO",$JOB))
WRITE !!,"Nothing to Report.",!!
GOTO END
+25 FOR
SET PSDT=$ORDER(^TMP("PSDO",$JOB,PSDT))
IF PSDT']""!PSDOUT
QUIT
Begin DoDot:1
+26 IF $Y+5>IOSL
DO HEADER
IF PSDOUT
QUIT
WRITE !!,"Drug => ",PSDT
SET PSDT(1)=0
+27 FOR
SET PSDT(1)=$ORDER(^TMP("PSDO",$JOB,PSDT,PSDT(1)))
IF 'PSDT(1)!PSDOUT
QUIT
Begin DoDot:2
+28 SET PSDT(2)=""
+29 FOR
SET PSDT(2)=$ORDER(^TMP("PSDO",$JOB,PSDT,PSDT(1),PSDT(2)))
IF PSDT(2)=""!PSDOUT
QUIT
Begin DoDot:3
+30 IF $Y+4>IOSL
DO HEADER
IF PSDOUT
QUIT
WRITE !!,PSDT," (continued)"
+31 WRITE !!,PSDT(1)," (",PSDT(2),")"
+32 SET PSDT(3)=$GET(^TMP("PSDO",$JOB,PSDT,PSDT(1),PSDT(2)))
+33 WRITE ?9,$JUSTIFY($PIECE(PSDT(3),U),4)
SET Y=$PIECE(PSDT(3),U,2)
XECUTE ^DD("DD")
WRITE ?20,Y
+34 WRITE ?40,$PIECE(PSDT(3),U,3)
End DoDot:3
IF PSDOUT
QUIT
End DoDot:2
IF PSDOUT
QUIT
End DoDot:1
IF PSDOUT
QUIT
END IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST)="C"
IF 'PSDOUT
SET DIR(0)="EA"
SET DIR("A")="END OF REPORT! Press <RET> to return to the menu."
WRITE !
DO ^DIR
+2 DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 DO KVAR^VADPT
KILL IO("Q"),VA("PID"),VA("BID"),^TMP("PSDO",$JOB)
+4 QUIT
IF PG
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET PSDOUT=1
QUIT
+1 IF $$S^%ZTLOAD
WRITE !!,"Task #",$GET(ZTSK),", ",$GET(ZTDESC)," was stopped by ",$PIECE($GET(^VA(200,+$GET(DUZ),0)),U),"."
SET PSDOUT=1
+2 IF $Y
WRITE @IOF
SET $PIECE(LN,"-",81)=""
SET PG=PG+1
WRITE !,"Outpatient Activity from ",PSDTB(2)," to ",PSDTB(3),?70,"PAGE: ",PG,!,LN,!,"Rx#",?10,"QTY",?20,"Fill Date",?40,"Patient",!,LN
+3 QUIT
SAVE ;
+1 SET ZTSAVE("^TMP(""PSD"",$J,")=""
+2 SET (ZTSAVE("PSDT"),ZTSAVE("PSDLOC"),ZTSAVE("PSDTB"),ZTSAVE("PSDTB("))=""
+3 QUIT