PSDOPTN ;BIR/LTL - Review OP Transactions for a Drug (cont.) ; 24 Jan 95
;;3.0;CONTROLLED SUBSTANCES ;**18,55,75,85**;13 Feb 97;Build 2
;
;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
...S PSDCMOP=0
...I $D(^PSRX(PSDT(1),4)) S PSDCMP=0 F S PSDCMP=$O(^PSRX(PSDT(1),4,PSDCMP)) Q:'PSDCMP D
....I +$P(^PSRX(PSDT(1),4,PSDCMP,0),U,3)=+PSDT(4),$P(^PSRX(PSDT(1),4,PSDCMP,0),U,4)<3 S PSDCMOP=1
...;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")_")"
...I $G(PSDCMOP) S PSDCMOP=0 Q
...S:$P(PSDT(5),U)]"" ^TMP("PSDO",$J,PSDT(2),$P(PSDT(5),U),PSDT(4))=PSDT(6)_U_PSDT_U_PSDT(7)
K PSDCMP
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),PSDCMOP
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
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDOPTN 4252 printed Nov 22, 2024@16:57:32 Page 2
PSDOPTN ;BIR/LTL - Review OP Transactions for a Drug (cont.) ; 24 Jan 95
+1 ;;3.0;CONTROLLED SUBSTANCES ;**18,55,75,85**;13 Feb 97;Build 2
+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 SET PSDCMOP=0
+10 IF $DATA(^PSRX(PSDT(1),4))
SET PSDCMP=0
FOR
SET PSDCMP=$ORDER(^PSRX(PSDT(1),4,PSDCMP))
if 'PSDCMP
QUIT
Begin DoDot:4
+11 IF +$PIECE(^PSRX(PSDT(1),4,PSDCMP,0),U,3)=+PSDT(4)
IF $PIECE(^PSRX(PSDT(1),4,PSDCMP,0),U,4)<3
SET PSDCMOP=1
End DoDot:4
+12 ;Returned to stock?
+13 if $SELECT('PSDT(4)
QUIT
+14 ;posted to the vault?
+15 SET PSDT(3)=0
+16 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
+17 if PSDT(3)
QUIT
+18 ;suspended & printed
+19 SET (PSDT(3),PSDT(8))=0
+20 IF PSDT>DT
Begin DoDot:4
+21 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
+22 ;quantity
+23 SET PSDT(6)=$SELECT('PSDT(4):$PIECE(PSDT(5),U,7),1:$PIECE($GET(^PSRX(PSDT(1),1,PSDT(4),0)),U,4))
+24 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
+25 SET PSDT(7)=Y
DO PID^VADPT6
SET PSDT(7)=PSDT(7)_" ("_VA("BID")_")"
+26 IF $GET(PSDCMOP)
SET PSDCMOP=0
QUIT
+27 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
+28 KILL PSDCMP
+29 IF '$DATA(^TMP("PSDO",$JOB))
WRITE !!,"Nothing to Report.",!!
GOTO END
+30 FOR
SET PSDT=$ORDER(^TMP("PSDO",$JOB,PSDT))
if PSDT']""!PSDOUT
QUIT
Begin DoDot:1
+31 if $Y+5>IOSL
DO HEADER
if PSDOUT
QUIT
WRITE !!,"Drug => ",PSDT
SET PSDT(1)=0
+32 FOR
SET PSDT(1)=$ORDER(^TMP("PSDO",$JOB,PSDT,PSDT(1)))
if 'PSDT(1)!PSDOUT
QUIT
Begin DoDot:2
+33 SET PSDT(2)=""
+34 FOR
SET PSDT(2)=$ORDER(^TMP("PSDO",$JOB,PSDT,PSDT(1),PSDT(2)))
if PSDT(2)=""!PSDOUT
QUIT
Begin DoDot:3
+35 IF $Y+4>IOSL
DO HEADER
if PSDOUT
QUIT
WRITE !!,PSDT," (continued)"
+36 WRITE !!,PSDT(1)," (",PSDT(2),")"
+37 SET PSDT(3)=$GET(^TMP("PSDO",$JOB,PSDT,PSDT(1),PSDT(2)))
+38 WRITE ?9,$JUSTIFY($PIECE(PSDT(3),U),4)
SET Y=$PIECE(PSDT(3),U,2)
XECUTE ^DD("DD")
WRITE ?20,Y
+39 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),PSDCMOP
+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