- PSAREVD ;BIR/LTL-Drug Receipt History Review ;7/23/97
- ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**15**; 10/24/97
- ;This routine reviews receipt transactions for a drug.
- ;
- ;References to ^PSDRUG( are covered by IA #2095
- ;References to ^PRC( are covered by IA #214
- ;References to ^PRCS( are covered by IA #198
- ;
- N DIC,DIR,DTOUT,DUOUT,PSA,PSACNT,PSALOCN,PSAR,PSAU,PSAOUT,PSAT,X,Y S PSAOUT=1,PSAU=0
- LOOK D ^PSADA I '$G(PSALOC) S PSAOUT=1 G END
- I '$O(^PSD(58.8,PSALOC,1,0)) W !!,"There are no drugs in ",PSALOCN G END
- S PSACNT=0 W !!,"You may select one, several, or ^ALL drugs.",!
- CHKD F S DIC="^PSD(58.8,+PSALOC,1,",DIC(0)="AEMQ",DIC("A")="Please Select "_PSALOCN_"'s Drug: ",DIC("S")="I $S($G(^(""I"")):$G(^(""I""))>DT,1:1)" W ! D ^DIC K DIC G:X'="^ALL"&(Y<1)&('PSACNT) END Q:Y<0 S PSA(+Y)="",PSACNT=PSACNT+1
- I PSACNT=1&('$O(^PSD(58.81,"F",+$O(PSA(0)),0))) W !!,"There have been no receipts for this drug.",!! G END
- I X="^ALL" F S PSAU=$O(^PSD(58.8,+PSALOC,1,PSAU)) Q:'PSAU S PSA(PSAU)=""
- S DIR(0)="D:AEP",DIR("A")="How far back in time do you want to go? ",DIR("B")="T-6M",DIR("?")="I will list receipts for your selected drug(s) within the last six months if you press return" W ! D ^DIR K DIR G:$D(DIRUT) END
- S PSAT=Y
- DEV ;asks device and queueing info
- K IO("Q"),PSALOC N %ZIS,IOP,POP S %ZIS="Q" 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^PSAREVD",ZTDESC="Drug receipt transaction review",ZTSAVE("PSA*")="" D ^%ZTLOAD,HOME^%ZIS S PSAOUT=1 G END
- START ;compiles and prints output
- N %DT,PSALN,PSAR,PSAPG,PSARPDT S (PSAPG,PSAOUT)=0,Y=DT,PSAR="" X ^DD("DD") S PSARPDT=Y,PSAU(1)=$O(PSA(0)) D HEADER S PSAU=0
- F S PSAU=$O(PSA(PSAU)) Q:'PSAU K PSAR(1) D G:PSAOUT END I 'PSAR,$O(PSA(PSAU)) S PSAU(1)=$O(PSA(PSAU))
- LOOP .F S PSAR=$O(^PSD(58.81,"F",PSAU,PSAR)) Q:'PSAR D:$Y+6>IOSL HEADER Q:PSAOUT S PSAR(2)=$G(^PSD(58.81,+PSAR,0)) D:$P(PSAR(2),U,4)'<PSAT&($P(PSAR(2),U,2)=1)
- ..S PSAR(1)=$G(PSAR(1))+1 W:PSAR(1)=1 $P($G(^PSDRUG(+PSAU,0)),U),!
- ..I '$D(PSALOC) S PSALOC=$P(PSAR(2),U,3) W !,"Receiving Site: ",$P($G(^PSD(58.8,+PSALOC,0)),U),!
- ..I $G(PSALOC)'=$P(PSAR(2),U,3) S PSALOC=$P(PSAR(2),U,3) W !,"Receiving site: ",$P($G(^PSD(58.8,+PSALOC,0)),U),!
- ..S Y=$E($P(PSAR(2),U,4),1,12) X ^DD("DD") W !,Y," -> "
- ..W $P(PSAR(2),U,6)," received by ",$P($G(^VA(200,+$P(PSAR(2),U,7),0)),U),!!
- ..W:$P($G(^PRC(442,+$P(PSAR(2),U,9),0)),U) "PO#: ",$P($G(^(0)),U),?20
- ..W:$P($G(^PRCS(410,+$P(PSAR(2),U,8),0)),U) "TR#: ",$P($G(^(0)),U)," "
- ..W:$P($G(^PSD(58.81,+PSAR,8)),U)]"" "INV#: ",$P($G(^(8)),U)
- ..W !,PSALN,!
- END W:$E(IOST)'="C" @IOF
- I $E(IOST,1,2)="C-",'PSAOUT 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-",PSAPG S DIR(0)="E" D ^DIR K DIR I 'Y S PSAOUT=1 Q
- I $$S^%ZTLOAD W !!,"Task #",$G(ZTSK),", ",$G(ZTDESC)," was stopped by ",$P($G(^VA(200,+$G(DUZ),0)),U),"." S PSAOUT=1 Q
- W:$Y @IOF S $P(PSALN,"-",81)="",PSAPG=PSAPG+1 W !?2,"History of Drug Receipts",?50,PSARPDT,?70,"PAGE: ",PSAPG,!,PSALN,!
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSAREVD 3196 printed Feb 18, 2025@23:16:57 Page 2
- PSAREVD ;BIR/LTL-Drug Receipt History Review ;7/23/97
- +1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**15**; 10/24/97
- +2 ;This routine reviews receipt transactions for a drug.
- +3 ;
- +4 ;References to ^PSDRUG( are covered by IA #2095
- +5 ;References to ^PRC( are covered by IA #214
- +6 ;References to ^PRCS( are covered by IA #198
- +7 ;
- +8 NEW DIC,DIR,DTOUT,DUOUT,PSA,PSACNT,PSALOCN,PSAR,PSAU,PSAOUT,PSAT,X,Y
- SET PSAOUT=1
- SET PSAU=0
- LOOK DO ^PSADA
- IF '$GET(PSALOC)
- SET PSAOUT=1
- GOTO END
- +1 IF '$ORDER(^PSD(58.8,PSALOC,1,0))
- WRITE !!,"There are no drugs in ",PSALOCN
- GOTO END
- +2 SET PSACNT=0
- WRITE !!,"You may select one, several, or ^ALL drugs.",!
- CHKD FOR
- SET DIC="^PSD(58.8,+PSALOC,1,"
- SET DIC(0)="AEMQ"
- SET DIC("A")="Please Select "_PSALOCN_"'s Drug: "
- SET DIC("S")="I $S($G(^(""I"")):$G(^(""I""))>DT,1:1)"
- WRITE !
- DO ^DIC
- KILL DIC
- if X'="^ALL"&(Y<1)&('PSACNT)
- GOTO END
- if Y<0
- QUIT
- SET PSA(+Y)=""
- SET PSACNT=PSACNT+1
- +1 IF PSACNT=1&('$ORDER(^PSD(58.81,"F",+$ORDER(PSA(0)),0)))
- WRITE !!,"There have been no receipts for this drug.",!!
- GOTO END
- +2 IF X="^ALL"
- FOR
- SET PSAU=$ORDER(^PSD(58.8,+PSALOC,1,PSAU))
- if 'PSAU
- QUIT
- SET PSA(PSAU)=""
- +3 SET DIR(0)="D:AEP"
- SET DIR("A")="How far back in time do you want to go? "
- SET DIR("B")="T-6M"
- SET DIR("?")="I will list receipts for your selected drug(s) within the last six months if you press return"
- WRITE !
- DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO END
- +4 SET PSAT=Y
- DEV ;asks device and queueing info
- +1 KILL IO("Q"),PSALOC
- NEW %ZIS,IOP,POP
- SET %ZIS="Q"
- 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^PSAREVD"
- SET ZTDESC="Drug receipt transaction review"
- SET ZTSAVE("PSA*")=""
- DO ^%ZTLOAD
- DO HOME^%ZIS
- SET PSAOUT=1
- GOTO END
- START ;compiles and prints output
- +1 NEW %DT,PSALN,PSAR,PSAPG,PSARPDT
- SET (PSAPG,PSAOUT)=0
- SET Y=DT
- SET PSAR=""
- XECUTE ^DD("DD")
- SET PSARPDT=Y
- SET PSAU(1)=$ORDER(PSA(0))
- DO HEADER
- SET PSAU=0
- +2 FOR
- SET PSAU=$ORDER(PSA(PSAU))
- if 'PSAU
- QUIT
- KILL PSAR(1)
- Begin DoDot:1
- LOOP FOR
- SET PSAR=$ORDER(^PSD(58.81,"F",PSAU,PSAR))
- if 'PSAR
- QUIT
- if $Y+6>IOSL
- DO HEADER
- if PSAOUT
- QUIT
- SET PSAR(2)=$GET(^PSD(58.81,+PSAR,0))
- if $PIECE(PSAR(2),U,4)'<PSAT&($PIECE(PSAR(2),U,2)=1)
- Begin DoDot:2
- +1 SET PSAR(1)=$GET(PSAR(1))+1
- if PSAR(1)=1
- WRITE $PIECE($GET(^PSDRUG(+PSAU,0)),U),!
- +2 IF '$DATA(PSALOC)
- SET PSALOC=$PIECE(PSAR(2),U,3)
- WRITE !,"Receiving Site: ",$PIECE($GET(^PSD(58.8,+PSALOC,0)),U),!
- +3 IF $GET(PSALOC)'=$PIECE(PSAR(2),U,3)
- SET PSALOC=$PIECE(PSAR(2),U,3)
- WRITE !,"Receiving site: ",$PIECE($GET(^PSD(58.8,+PSALOC,0)),U),!
- +4 SET Y=$EXTRACT($PIECE(PSAR(2),U,4),1,12)
- XECUTE ^DD("DD")
- WRITE !,Y," -> "
- +5 WRITE $PIECE(PSAR(2),U,6)," received by ",$PIECE($GET(^VA(200,+$PIECE(PSAR(2),U,7),0)),U),!!
- +6 if $PIECE($GET(^PRC(442,+$PIECE(PSAR(2),U,9),0)),U)
- WRITE "PO#: ",$PIECE($GET(^(0)),U),?20
- +7 if $PIECE($GET(^PRCS(410,+$PIECE(PSAR(2),U,8),0)),U)
- WRITE "TR#: ",$PIECE($GET(^(0)),U)," "
- +8 if $PIECE($GET(^PSD(58.81,+PSAR,8)),U)]""
- WRITE "INV#: ",$PIECE($GET(^(8)),U)
- +9 WRITE !,PSALN,!
- End DoDot:2
- End DoDot:1
- if PSAOUT
- GOTO END
- IF 'PSAR
- IF $ORDER(PSA(PSAU))
- SET PSAU(1)=$ORDER(PSA(PSAU))
- END if $EXTRACT(IOST)'="C"
- WRITE @IOF
- +1 IF $EXTRACT(IOST,1,2)="C-"
- IF 'PSAOUT
- 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 PSAPG
- SET DIR(0)="E"
- DO ^DIR
- KILL DIR
- IF 'Y
- SET PSAOUT=1
- QUIT
- +2 IF $$S^%ZTLOAD
- WRITE !!,"Task #",$GET(ZTSK),", ",$GET(ZTDESC)," was stopped by ",$PIECE($GET(^VA(200,+$GET(DUZ),0)),U),"."
- SET PSAOUT=1
- QUIT
- +3 if $Y
- WRITE @IOF
- SET $PIECE(PSALN,"-",81)=""
- SET PSAPG=PSAPG+1
- WRITE !?2,"History of Drug Receipts",?50,PSARPDT,?70,"PAGE: ",PSAPG,!,PSALN,!
- +4 QUIT