PSGWBOA ;BHAM ISC/CML-Print Backorder Report by AOU or Item (ALL Current Backorders) ; 03 Sep 93 / 12:23 PM
;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
W !!,"This option will print a list of ALL Current Backorders.",!
ASK R !,"Do you want to sort by (A)rea of Use or by (I)tem? ",SORT:DTIME S:'$T SORT="^" G:"^"[SORT QUIT I SORT'="A"&(SORT'="I") W *7,!?5,"Enter 'A' to sort by Area of Use, 'I' to sort by Item, or '^' to Exit.",! G ASK
W !!,"Right margin for this report is 80 columns.",!,"You may queue the report to print at a later time.",!!
DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G QUIT
I $D(IO("Q")) K IO("Q") S PSGWIO=ION,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="ENQ^PSGWBOA",ZTDESC="Compile data for AOU/ITEM Backorder report",ZTSAVE("PSGWIO")="",ZTSAVE("SORT")="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G QUIT
U IO
;
ENQ ;ENTRY POINT WHEN QUEUED
K ^TMP("PSGWBOA",$J) F BODA=0:0 S BODA=$O(^PSI(58.3,BODA)) G:'BODA&($D(ZTQUEUED)) PRTQUE G:'BODA PRT1 I $D(^PSI(58.3,BODA,0)) S DRGDA=$P(^(0),"^") D BUILD
;
BUILD ;
Q:'$D(^PSDRUG(DRGDA,0)) I '$O(^PSI(58.3,BODA,0)) S DIK="^PSI(58.3,",DA=BODA D ^DIK K DIK,DA Q
S DNM=$S($P(^PSDRUG(DRGDA,0),"^")]"":$P(^(0),"^"),1:"UNKNOWN")
F AOU=0:0 S AOU=$O(^PSI(58.3,BODA,1,AOU)) Q:'AOU I $D(^(AOU,0)) F BO=0:0 S BO=$O(^PSI(58.3,BODA,1,AOU,1,BO)) Q:'BO I $D(^(BO,0)),$P(^(0),"^",5)="" S QQ=^(0) D SETGL
Q
SETGL ;
S BODT=$P(QQ,"^"),CB=$P(QQ,"^",2),ANM=$S($D(^PSI(58.1,AOU,0)):$P(^(0),"^"),1:"AOU NAME MISSING") I CB>0,$D(^PSI(58.1,AOU,"I")),^("I"),^("I")'>DT S ANM=ANM_" **"
S LOC="" I $O(^PSI(58.1,AOU,1,"B",DRGDA,0)) S ITMDA=$O(^(0)) I $D(^PSI(58.1,AOU,1,ITMDA,0)) S LOC=$P(^(0),"^",8)
S:LOC="" LOC="UNKNOWN" I SORT="I" S ^TMP("PSGWBOA",$J,DNM,ANM,BODT)=LOC_"^"_CB Q
S ^TMP("PSGWBOA",$J,ANM,DNM,BODT)=LOC_"^"_CB Q
;
PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
K ZTSAVE,ZTIO S ZTIO=PSGWIO,ZTRTN="PRT1^PSGWBOA",ZTDESC="Print Data for Backorder AOU/Item List",ZTDTH=$H,ZTSAVE("^TMP(""PSGWBOA"",$J,")="",ZTSAVE("SORT")=""
D ^%ZTLOAD K ^TMP("PSGWBOA",$J) G QUIT
PRT1 ;
S $P(LN,"-",81)="",PG=0,%DT="",(S1,S2,QFLG)="" S HDT=$$PSGWDT^PSGWUTL1 D HDR
I '$D(^TMP("PSGWBOA",$J)) W !?17,"***** NO DATA AVAILABLE FOR THIS REPORT *****" S QFLG=1 G DONE
F LL=0:0 S TOT=0,S1=$O(^TMP("PSGWBOA",$J,S1)) Q:S1="" D:$Y+6>IOSL PRTCHK Q:QFLG W !!,"=> ",S1 S:S1["**" INACT=1 D PRT2 Q:QFLG
DONE D:'QFLG INACT I $E(IOST)'="C" W @IOF
I $E(IOST)="C" D:'QFLG SS^PSGWUTL1
QUIT ;
K %DT,%,%H,%I,BO,BODA,BODT,CB,DIC,SORT,DRGDA,ITMDA,JJ,LOC,TOT,AOU,S1,S2,HDT,INACT,LL,LN,LNS,QQ,PG,X,Y,QFLG,ANS
K ^TMP("PSGWBOA",$J),PSGWIO,ZTSK,ZTIO,DA,DNM,ANM,HF,IO("Q") D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@" Q
PRT2 F LL=0:0 S S2=$O(^TMP("PSGWBOA",$J,S1,S2)) D:SORT="I" TOT Q:QFLG Q:S2="" F BODT=0:0 S BODT=$O(^TMP("PSGWBOA",$J,S1,S2,BODT)) Q:'BODT D DATA Q:QFLG
Q
DATA ;
S LOC=$P(^TMP("PSGWBOA",$J,S1,S2,BODT),"^"),CB=$P(^(BODT),"^",2),TOT=TOT+CB Q:CB<1 I $Y+6>IOSL D PRTCHK Q:QFLG
S Y=$E(BODT,1,12) X ^DD("DD") W !?7,S2
I SORT="A" W ?53,Y,?73,$J(CB,6),!?17,LOC Q
W ?40,LOC,?54,Y,?73,$J(CB,6) Q
TOT ;
S:S2["**" INACT=1 I S2="",'QFLG D:$Y+6>IOSL PRTCHK Q:QFLG W !?72,"-------",!?66,"TOTAL:",?72,$J(TOT,7) Q
Q
HDR ;
S INACT=0 W:$Y @IOF S PG=PG+1
I SORT="I" W !?25,"PHARMACY BACKORDER LIST BY ITEM",?71,"PAGE: ",PG,!?28,"PRINTED: ",HDT,!!,"=> ","ITEM",?56,"DATE/TIME FOR",?72,"CURRENT",!?12,"AOU",?42,"LOCATION",?58,"BACKORDER",?71,"BACKORDER",!,LN Q
W !?26,"PHARMACY BACKORDER LIST BY AOU",?71,"PAGE: ",PG,!?28,"PRINTED: ",HDT,!!,"=> ","AOU",!?12,"ITEM",?56,"DATE/TIME FOR",?72,"CURRENT",!?19,"LOCATION",?58,"BACKORDER",?71,"BACKORDER",!,LN
Q
INACT I INACT F LNS=1:1:((IOSL-$Y)-3) W !
I W "** Indicates an Inactive AOU"
Q
PRTCHK ;
D INACT I $E(IOST)="C" W !!,"Press <RETURN> to Continue or ""^"" to Exit: " R ANS:DTIME S:'$T ANS="^" D:ANS?1."?" HELP^PSGWUTL1 I ANS="^" S QFLG=1 Q
D HDR Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGWBOA 3936 printed Dec 13, 2024@01:38:55 Page 2
PSGWBOA ;BHAM ISC/CML-Print Backorder Report by AOU or Item (ALL Current Backorders) ; 03 Sep 93 / 12:23 PM
+1 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
+2 WRITE !!,"This option will print a list of ALL Current Backorders.",!
ASK READ !,"Do you want to sort by (A)rea of Use or by (I)tem? ",SORT:DTIME
if '$TEST
SET SORT="^"
if "^"[SORT
GOTO QUIT
IF SORT'="A"&(SORT'="I")
WRITE *7,!?5,"Enter 'A' to sort by Area of Use, 'I' to sort by Item, or '^' to Exit.",!
GOTO ASK
+1 WRITE !!,"Right margin for this report is 80 columns.",!,"You may queue the report to print at a later time.",!!
DEV KILL %ZIS,IOP
SET %ZIS="QM"
SET %ZIS("B")=""
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO QUIT
+1 IF $DATA(IO("Q"))
KILL IO("Q")
SET PSGWIO=ION
SET ZTIO=""
KILL ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="ENQ^PSGWBOA"
SET ZTDESC="Compile data for AOU/ITEM Backorder report"
SET ZTSAVE("PSGWIO")=""
SET ZTSAVE("SORT")=""
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO QUIT
+2 USE IO
+3 ;
ENQ ;ENTRY POINT WHEN QUEUED
+1 KILL ^TMP("PSGWBOA",$JOB)
FOR BODA=0:0
SET BODA=$ORDER(^PSI(58.3,BODA))
if 'BODA&($DATA(ZTQUEUED))
GOTO PRTQUE
if 'BODA
GOTO PRT1
IF $DATA(^PSI(58.3,BODA,0))
SET DRGDA=$PIECE(^(0),"^")
DO BUILD
+2 ;
BUILD ;
+1 if '$DATA(^PSDRUG(DRGDA,0))
QUIT
IF '$ORDER(^PSI(58.3,BODA,0))
SET DIK="^PSI(58.3,"
SET DA=BODA
DO ^DIK
KILL DIK,DA
QUIT
+2 SET DNM=$SELECT($PIECE(^PSDRUG(DRGDA,0),"^")]"":$PIECE(^(0),"^"),1:"UNKNOWN")
+3 FOR AOU=0:0
SET AOU=$ORDER(^PSI(58.3,BODA,1,AOU))
if 'AOU
QUIT
IF $DATA(^(AOU,0))
FOR BO=0:0
SET BO=$ORDER(^PSI(58.3,BODA,1,AOU,1,BO))
if 'BO
QUIT
IF $DATA(^(BO,0))
IF $PIECE(^(0),"^",5)=""
SET QQ=^(0)
DO SETGL
+4 QUIT
SETGL ;
+1 SET BODT=$PIECE(QQ,"^")
SET CB=$PIECE(QQ,"^",2)
SET ANM=$SELECT($DATA(^PSI(58.1,AOU,0)):$PIECE(^(0),"^"),1:"AOU NAME MISSING")
IF CB>0
IF $DATA(^PSI(58.1,AOU,"I"))
IF ^("I")
IF ^("I")'>DT
SET ANM=ANM_" **"
+2 SET LOC=""
IF $ORDER(^PSI(58.1,AOU,1,"B",DRGDA,0))
SET ITMDA=$ORDER(^(0))
IF $DATA(^PSI(58.1,AOU,1,ITMDA,0))
SET LOC=$PIECE(^(0),"^",8)
+3 if LOC=""
SET LOC="UNKNOWN"
IF SORT="I"
SET ^TMP("PSGWBOA",$JOB,DNM,ANM,BODT)=LOC_"^"_CB
QUIT
+4 SET ^TMP("PSGWBOA",$JOB,ANM,DNM,BODT)=LOC_"^"_CB
QUIT
+5 ;
PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
+1 KILL ZTSAVE,ZTIO
SET ZTIO=PSGWIO
SET ZTRTN="PRT1^PSGWBOA"
SET ZTDESC="Print Data for Backorder AOU/Item List"
SET ZTDTH=$HOROLOG
SET ZTSAVE("^TMP(""PSGWBOA"",$J,")=""
SET ZTSAVE("SORT")=""
+2 DO ^%ZTLOAD
KILL ^TMP("PSGWBOA",$JOB)
GOTO QUIT
PRT1 ;
+1 SET $PIECE(LN,"-",81)=""
SET PG=0
SET %DT=""
SET (S1,S2,QFLG)=""
SET HDT=$$PSGWDT^PSGWUTL1
DO HDR
+2 IF '$DATA(^TMP("PSGWBOA",$JOB))
WRITE !?17,"***** NO DATA AVAILABLE FOR THIS REPORT *****"
SET QFLG=1
GOTO DONE
+3 FOR LL=0:0
SET TOT=0
SET S1=$ORDER(^TMP("PSGWBOA",$JOB,S1))
if S1=""
QUIT
if $Y+6>IOSL
DO PRTCHK
if QFLG
QUIT
WRITE !!,"=> ",S1
if S1["**"
SET INACT=1
DO PRT2
if QFLG
QUIT
DONE if 'QFLG
DO INACT
IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST)="C"
if 'QFLG
DO SS^PSGWUTL1
QUIT ;
+1 KILL %DT,%,%H,%I,BO,BODA,BODT,CB,DIC,SORT,DRGDA,ITMDA,JJ,LOC,TOT,AOU,S1,S2,HDT,INACT,LL,LN,LNS,QQ,PG,X,Y,QFLG,ANS
+2 KILL ^TMP("PSGWBOA",$JOB),PSGWIO,ZTSK,ZTIO,DA,DNM,ANM,HF,IO("Q")
DO ^%ZISC
+3 if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT
PRT2 FOR LL=0:0
SET S2=$ORDER(^TMP("PSGWBOA",$JOB,S1,S2))
if SORT="I"
DO TOT
if QFLG
QUIT
if S2=""
QUIT
FOR BODT=0:0
SET BODT=$ORDER(^TMP("PSGWBOA",$JOB,S1,S2,BODT))
if 'BODT
QUIT
DO DATA
if QFLG
QUIT
+1 QUIT
DATA ;
+1 SET LOC=$PIECE(^TMP("PSGWBOA",$JOB,S1,S2,BODT),"^")
SET CB=$PIECE(^(BODT),"^",2)
SET TOT=TOT+CB
if CB<1
QUIT
IF $Y+6>IOSL
DO PRTCHK
if QFLG
QUIT
+2 SET Y=$EXTRACT(BODT,1,12)
XECUTE ^DD("DD")
WRITE !?7,S2
+3 IF SORT="A"
WRITE ?53,Y,?73,$JUSTIFY(CB,6),!?17,LOC
QUIT
+4 WRITE ?40,LOC,?54,Y,?73,$JUSTIFY(CB,6)
QUIT
TOT ;
+1 if S2["**"
SET INACT=1
IF S2=""
IF 'QFLG
if $Y+6>IOSL
DO PRTCHK
if QFLG
QUIT
WRITE !?72,"-------",!?66,"TOTAL:",?72,$JUSTIFY(TOT,7)
QUIT
+2 QUIT
HDR ;
+1 SET INACT=0
if $Y
WRITE @IOF
SET PG=PG+1
+2 IF SORT="I"
WRITE !?25,"PHARMACY BACKORDER LIST BY ITEM",?71,"PAGE: ",PG,!?28,"PRINTED: ",HDT,!!,"=> ","ITEM",?56,"DATE/TIME FOR",?72,"CURRENT",!?12,"AOU",?42,"LOCATION",?58,"BACKORDER",?71,"BACKORDER",!,LN
QUIT
+3 WRITE !?26,"PHARMACY BACKORDER LIST BY AOU",?71,"PAGE: ",PG,!?28,"PRINTED: ",HDT,!!,"=> ","AOU",!?12,"ITEM",?56,"DATE/TIME FOR",?72,"CURRENT",!?19,"LOCATION",?58,"BACKORDER",?71,"BACKORDER",!,LN
+4 QUIT
INACT IF INACT
FOR LNS=1:1:((IOSL-$Y)-3)
WRITE !
+1 IF $TEST
WRITE "** Indicates an Inactive AOU"
+2 QUIT
PRTCHK ;
+1 DO INACT
IF $EXTRACT(IOST)="C"
WRITE !!,"Press <RETURN> to Continue or ""^"" to Exit: "
READ ANS:DTIME
if '$TEST
SET ANS="^"
if ANS?1."?"
DO HELP^PSGWUTL1
IF ANS="^"
SET QFLG=1
QUIT
+2 DO HDR
QUIT