PSDADJD ;BIR/LTL-Review Adjustment Transactions for a Drug; 2 Nov 94 [ 11/02/94 3:53 PM ]
;;3.0; CONTROLLED SUBSTANCES ;**18,36**;13 Feb 97
;
;References to ^PSD(58.8, covered by DBIA2711
;References to PSD(58.81 are covered by DBIA2808
;References to ^PSDRUG( are covered by DBIA221
N PSDOUT I '$D(PSDSITE) D ^PSDSET I '$D(PSDSITE) S PSDOUT=1 G END
N C,CNT,DIC,DIR,DTOUT,DUOUT,PSD,PSDA,PSDC,PSDEV,PSDR,PSDU,PSDLOC,PSDLOCN,PSDT,PSDTB,X,Y S PSDOUT=1,(CNT,PSDU)=0,PSDCHO=2
D DT^DICRW
S PSDLOC=$P(PSDSITE,U,3),PSDLOCN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) CHKD
LOOK S DIC="^PSD(58.8,",DIC(0)="AEQ",DIC("A")="Select Dispensing Site: "
S DIC("S")="I $P($G(^(0)),U,3)=+PSDSITE,$S($P($G(^(0)),U,2)[""M"":1,$P($G(^(0)),U,2)[""S"":1,1:0),($S('$D(^(""I"")):1,+^(""I"")>DT:1,'^(""I""):1,1:0))"
S DIC("B")=$P(PSDSITE,U,4)
W ! D ^DIC K DIC G:Y<0 END S PSDLOC=+Y,PSDLOCN=$P(Y,U,2)
S $P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=$P(Y,U,2)
W !!,"You may select one, several, or ^ALL drugs."
CHKD F S DIC="^PSD(58.8,+PSDLOC,1,",DIC(0)="AEMQZ",DIC("A")="Please Select "_PSDLOCN_"'s Drug: ",DIC("S")="I $S($G(^(""I"")):$G(^(""I""))>DT,1:1)" W ! D ^DIC K DIC G:X'="^ALL"&(Y<1)&('CNT) END Q:Y<0 S PSD(Y(0,0))=+Y,PSDA(+Y)=Y(0,0),CNT=CNT+1
I CNT=1,'$O(^PSD(58.81,"F",+PSD($O(PSD(0))),"")) W !!,"There have been no adjustments for this drug.",!! G END
I X="^ALL" F S PSDU=$O(^PSD(58.8,+PSDLOC,1,PSDU)) Q:'PSDU S:$P($G(^PSDRUG(PSDU,0)),U)]"" PSD($P(^(0),U))=PSDU,PSDA(PSDU)=$P(^(0),U)
S DIR(0)="D^::AEPT",DIR("A")="Beginning date",DIR("?")="Adjustments will be listed for the selected drug(s) within the selected date range" W ! D ^DIR G:Y<1 END
S (PSDT,PSDTB)=Y,PSDTB(2)=Y(0),DIR(0)="DA^"_PSDT_":NOW:AEPT"
S DIR("A")="Ending date: ",DIR("B")="Now"
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
D G:Y<1 END
.S DIR(0)="S^1:DATE/DRUG (132 column;2:DRUG/DATE (80 column, browser)"
.S DIR("B")=1,DIR("?")="^S XQH=""PSD BALANCE ADJUSTMENT REPORT"" D EN^XQH" D ^DIR K DIR S PSDCHO=Y
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 ;asks device and queueing info
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=$S(PSDCHO=2:"START^PSDADJD",1:"START^PSDADJW"),ZTDESC="Drug adjustment transaction review",ZTSAVE("PSD*")="" D ^%ZTLOAD,HOME^%ZIS S PSDOUT=1 G END
;PSD*3*36 (11oct01 - USE SELECTED DEVICE Dave B.)
U IO
;Eop36
G:PSDCHO=1 ^PSDADJW
;(PSD*3*18 - Dave B changed next line to FM calls per SQA)
I $E(IOST)="C" D CHK I $G(GOOD)'<21,$$TEST^DDBRT W !!,"Getting ready to browse...",!! G ^PSDADJB
START ;compiles and prints output
N LN,PSDR,PG S (PG,PSDOUT)=0 D HEADER S PSDU=0
F S PSDU=$O(PSD(PSDU)) Q:PSDU']"" D G:PSDOUT END S PSDT=PSDTB,PSDT(1)=0
LOOP .F S PSDT=$O(^PSD(58.81,"ACT",PSDT)) W:$E(IOST)="C" "." Q:'PSDT!(PSDT>PSDTB(1)) D:$O(^PSD(58.81,"ACT",PSDT,0))=PSDLOC&($O(^PSD(58.81,"ACT",PSDT,PSDLOC,0))=PSD(PSDU))&($O(^PSD(58.81,"ACT",PSDT,PSDLOC,PSD(PSDU),9,0))) Q:PSDOUT
..S PSDR(2)=$G(^PSD(58.81,+$O(^PSD(58.81,"ACT",PSDT,PSDLOC,PSD(PSDU),9,0)),0))
..D:$Y+7>IOSL HEADER Q:PSDOUT
..S PSDT(1)=$G(PSDT(1))+1 W:PSDT(1)=1 !,PSDU,!
..S Y=$E($P(PSDR(2),U,4),1,12) X ^DD("DD") W !,Y," "," -> "
..W $P(PSDR(2),U,6)," adjusted by ",$P($G(^VA(200,+$P(PSDR(2),U,7),0)),U),!!
..W "Reason: ",$P(PSDR(2),U,16),!
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." D ^DIR
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@" K IO("Q")
Q
I $E(IOST,1,2)'="P-",PG S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 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,"-",80)="",PG=PG+1 W !,"Adjustments from ",PSDTB(2)," to ",PSDTB(3),?70,"PAGE: ",PG,!,LN W:$G(PSDT(1)) !,PSDU," (continued)",!
;
CHK ;(DAVE B 26OCT99)
;PSD*3*18 Had to change looking at 9.4 directly to FM calls (BS)
;
S DIC="^DIC(9.4,",DIC(0)="QZ",X="VA FILEMAN" D ^DIC I +Y'>0 S GOOD=0 Q
S GOOD=$$GET1^DIQ(9.4,+Y,13,"I")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDADJD 4247 printed Dec 13, 2024@01:44:52 Page 2
PSDADJD ;BIR/LTL-Review Adjustment Transactions for a Drug; 2 Nov 94 [ 11/02/94 3:53 PM ]
+1 ;;3.0; CONTROLLED SUBSTANCES ;**18,36**;13 Feb 97
+2 ;
+3 ;References to ^PSD(58.8, covered by DBIA2711
+4 ;References to PSD(58.81 are covered by DBIA2808
+5 ;References to ^PSDRUG( are covered by DBIA221
+6 NEW PSDOUT
IF '$DATA(PSDSITE)
DO ^PSDSET
IF '$DATA(PSDSITE)
SET PSDOUT=1
GOTO END
+7 NEW C,CNT,DIC,DIR,DTOUT,DUOUT,PSD,PSDA,PSDC,PSDEV,PSDR,PSDU,PSDLOC,PSDLOCN,PSDT,PSDTB,X,Y
SET PSDOUT=1
SET (CNT,PSDU)=0
SET PSDCHO=2
+8 DO DT^DICRW
+9 SET PSDLOC=$PIECE(PSDSITE,U,3)
SET PSDLOCN=$PIECE(PSDSITE,U,4)
+10 if $PIECE(PSDSITE,U,5)
GOTO CHKD
LOOK SET DIC="^PSD(58.8,"
SET DIC(0)="AEQ"
SET DIC("A")="Select Dispensing Site: "
+1 SET DIC("S")="I $P($G(^(0)),U,3)=+PSDSITE,$S($P($G(^(0)),U,2)[""M"":1,$P($G(^(0)),U,2)[""S"":1,1:0),($S('$D(^(""I"")):1,+^(""I"")>DT:1,'^(""I""):1,1:0))"
+2 SET DIC("B")=$PIECE(PSDSITE,U,4)
+3 WRITE !
DO ^DIC
KILL DIC
if Y<0
GOTO END
SET PSDLOC=+Y
SET PSDLOCN=$PIECE(Y,U,2)
+4 SET $PIECE(PSDSITE,U,3)=+Y
SET $PIECE(PSDSITE,U,4)=$PIECE(Y,U,2)
+5 WRITE !!,"You may select one, several, or ^ALL drugs."
CHKD FOR
SET DIC="^PSD(58.8,+PSDLOC,1,"
SET DIC(0)="AEMQZ"
SET DIC("A")="Please Select "_PSDLOCN_"'s Drug: "
SET DIC("S")="I $S($G(^(""I"")):$G(^(""I""))>DT,1:1)"
WRITE !
DO ^DIC
KILL DIC
if X'="^ALL"&(Y<1)&('CNT)
GOTO END
if Y<0
QUIT
SET PSD(Y(0,0))=+Y
SET PSDA(+Y)=Y(0,0)
SET CNT=CNT+1
+1 IF CNT=1
IF '$ORDER(^PSD(58.81,"F",+PSD($ORDER(PSD(0))),""))
WRITE !!,"There have been no adjustments for this drug.",!!
GOTO END
+2 IF X="^ALL"
FOR
SET PSDU=$ORDER(^PSD(58.8,+PSDLOC,1,PSDU))
if 'PSDU
QUIT
if $PIECE($GET(^PSDRUG(PSDU,0)),U)]""
SET PSD($PIECE(^(0),U))=PSDU
SET PSDA(PSDU)=$PIECE(^(0),U)
+3 SET DIR(0)="D^::AEPT"
SET DIR("A")="Beginning date"
SET DIR("?")="Adjustments will be listed for the selected drug(s) within the selected date range"
WRITE !
DO ^DIR
if Y<1
GOTO END
+4 SET (PSDT,PSDTB)=Y
SET PSDTB(2)=Y(0)
SET DIR(0)="DA^"_PSDT_":NOW:AEPT"
+5 SET DIR("A")="Ending date: "
SET DIR("B")="Now"
+6 WRITE !
DO ^DIR
KILL DIR
if Y<1
GOTO END
SET PSDTB(1)=Y
SET PSDTB(3)=Y(0)
+7 if '$PIECE(PSDTB(1),".",2)
SET PSDTB(1)=PSDTB(1)+.999999
+8 Begin DoDot:1
+9 SET DIR(0)="S^1:DATE/DRUG (132 column;2:DRUG/DATE (80 column, browser)"
+10 SET DIR("B")=1
SET DIR("?")="^S XQH=""PSD BALANCE ADJUSTMENT REPORT"" D EN^XQH"
DO ^DIR
KILL DIR
SET PSDCHO=Y
End DoDot:1
if Y<1
GOTO END
+11 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 ;asks device and queueing info
+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=$SELECT(PSDCHO=2:"START^PSDADJD",1:"START^PSDADJW")
SET ZTDESC="Drug adjustment transaction review"
SET ZTSAVE("PSD*")=""
DO ^%ZTLOAD
DO HOME^%ZIS
SET PSDOUT=1
GOTO END
+3 ;PSD*3*36 (11oct01 - USE SELECTED DEVICE Dave B.)
+4 USE IO
+5 ;Eop36
+6 if PSDCHO=1
GOTO ^PSDADJW
+7 ;(PSD*3*18 - Dave B changed next line to FM calls per SQA)
+8 IF $EXTRACT(IOST)="C"
DO CHK
IF $GET(GOOD)'<21
IF $$TEST^DDBRT
WRITE !!,"Getting ready to browse...",!!
GOTO ^PSDADJB
START ;compiles and prints output
+1 NEW LN,PSDR,PG
SET (PG,PSDOUT)=0
DO HEADER
SET PSDU=0
+2 FOR
SET PSDU=$ORDER(PSD(PSDU))
if PSDU']""
QUIT
Begin DoDot:1
LOOP FOR
SET PSDT=$ORDER(^PSD(58.81,"ACT",PSDT))
if $EXTRACT(IOST)="C"
WRITE "."
if 'PSDT!(PSDT>PSDTB(1))
QUIT
if $ORDER(^PSD(58.81,"ACT",PSDT,0))=PSDLOC&($ORDER(^PSD(58.81,"ACT",PSDT,PSDLOC,0))=PSD(PSDU))&($ORDER(^PSD(58.81,"ACT",PSDT,PSDLOC,PSD(PSDU),9,0)))
Begin DoDot:2
+1 SET PSDR(2)=$GET(^PSD(58.81,+$ORDER(^PSD(58.81,"ACT",PSDT,PSDLOC,PSD(PSDU),9,0)),0))
+2 if $Y+7>IOSL
DO HEADER
if PSDOUT
QUIT
+3 SET PSDT(1)=$GET(PSDT(1))+1
if PSDT(1)=1
WRITE !,PSDU,!
+4 SET Y=$EXTRACT($PIECE(PSDR(2),U,4),1,12)
XECUTE ^DD("DD")
WRITE !,Y," "," -> "
+5 WRITE $PIECE(PSDR(2),U,6)," adjusted by ",$PIECE($GET(^VA(200,+$PIECE(PSDR(2),U,7),0)),U),!!
+6 WRITE "Reason: ",$PIECE(PSDR(2),U,16),!
End DoDot:2
if PSDOUT
QUIT
End DoDot:1
if PSDOUT
GOTO END
SET PSDT=PSDTB
SET PSDT(1)=0
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."
DO ^DIR
+2 DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
KILL IO("Q")
+3 QUIT
+1 IF $EXTRACT(IOST,1,2)'="P-"
IF PG
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET PSDOUT=1
QUIT
+2 IF $$S^%ZTLOAD
WRITE !!,"Task #",$GET(ZTSK),", ",$GET(ZTDESC)," was stopped by ",$PIECE($GET(^VA(200,+$GET(DUZ),0)),U),"."
SET PSDOUT=1
+3 if $Y
WRITE @IOF
SET $PIECE(LN,"-",80)=""
SET PG=PG+1
WRITE !,"Adjustments from ",PSDTB(2)," to ",PSDTB(3),?70,"PAGE: ",PG,!,LN
if $GET(PSDT(1))
WRITE !,PSDU," (continued)",!
+4 ;
CHK ;(DAVE B 26OCT99)
+1 ;PSD*3*18 Had to change looking at 9.4 directly to FM calls (BS)
+2 ;
+3 SET DIC="^DIC(9.4,"
SET DIC(0)="QZ"
SET X="VA FILEMAN"
DO ^DIC
IF +Y'>0
SET GOOD=0
QUIT
+4 SET GOOD=$$GET1^DIQ(9.4,+Y,13,"I")
+5 QUIT