PSGWBOI ;BHAM ISC/CML-Print Backorder Report by Specific Item (Single or Multiple) ; 19 Mar 93 / 8:24 AM
;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
SINGLE ;ENTRY POINT FOR SINGLE ITEM
W ! K DIC,^TMP("PSGWQ",$J) S DIC="^PSI(58.3,",DIC(0)="QEAOM" D ^DIC K DIC G:Y<0 QUIT S BODA=+Y,DRGDA=$P(Y,"^",2) G START
MULTI ;ENTRY POINT FOR MULTIPLE ITEMS
W ! K DIC,^TMP("PSGWQ",$J) S DIC="^PSI(58.3,",DIC(0)="QEAOM" F JJ=0:0 D ^DIC Q:Y<0 S ^TMP("PSGWQ",$J,+Y)=$P(Y,"^",2)
I X="^"!('$D(^TMP("PSGWQ",$J))) G QUIT
START 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^PSGWBOI",ZTDESC="Compile data for ITEM Backorder report",ZTSAVE("PSGWIO")=""
I S:$D(^TMP("PSGWQ",$J)) ZTSAVE("^TMP(""PSGWQ"",$J,")="" S:$D(BODA) ZTSAVE("BODA")="" S:$D(DRGDA) ZTSAVE("DRGDA")="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G QUIT
U IO
;
ENQ ;ENTRY POINT WHEN QUEUED
K ^TMP("PSGWBOI",$J) I $D(BODA),$D(DRGDA) S HDRFLG="S" D BUILD G:$D(ZTQUEUED) PRTQUE G PRT1^PSGWBOIP
I $D(^TMP("PSGWQ",$J)) S HDRFLG="M" F BODA=0:0 S BODA=$O(^TMP("PSGWQ",$J,BODA)) G:'BODA&($D(ZTQUEUED)) PRTQUE G:'BODA PRT1^PSGWBOIP S DRGDA=$P(^(BODA),"^") D BUILD
;
BUILD ;
Q:'$D(^PSDRUG(DRGDA,0)) S DNM=$S($P(^(0),"^")]"":$P(^(0),"^"),1:"UNKNOWN")
I '$O(^PSI(58.3,BODA,0)) S ^TMP("PSGWBOI",$J,DNM,"ZZZ","ZZZ")="" Q
F AOU=0:0 S AOU=$O(^PSI(58.3,BODA,1,AOU)) Q:'AOU I $D(^(AOU,0)) D AOUCHK F BO=0:0 S BO=$O(^PSI(58.3,BODA,1,AOU,1,BO)) Q:'BO I $D(^(BO,0)) S QQ=^(0) D SETGL
Q
AOUCHK ;
I '$O(^PSI(58.3,BODA,1,AOU,1,0)) S ^TMP("PSGWBOI",$J,DNM,"ZZZ","ZZZ")=""
Q
SETGL ;
S BODT=$P(QQ,"^"),CURBO=$S($P(QQ,"^",5)="":$P(QQ,"^",2),1:0)
S ANM=$S($D(^PSI(58.1,AOU,0)):$P(^(0),"^"),1:"AOU NAME MISSING") I CURBO>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" S ^TMP("PSGWBOI",$J,DNM,ANM,BODT)=LOC_"^"_CURBO
Q
;
PRTQUE ;
K ZTSAVE,ZTIO S ZTIO=PSGWIO,ZTRTN="PRT1^PSGWBOIP",ZTDESC="Print Data for Backorder Item List",ZTDTH=$H,ZTSAVE("^TMP(""PSGWBOI"",$J,")="",ZTSAVE("HDRFLG")=""
D ^%ZTLOAD K ^TMP("PSGWQ",$J)
QUIT ;
K %DT,%,%H,%I,BO,BODA,BODT,CURBO,DIC,DNM,DRGDA,ITMDA,JJ,LOC,TOT,AOU,ANM,HDT,INACT,LL,LN,LNS,QQ,PG,X,Y
K ^TMP("PSGWBOI",$J),^TMP("PSGWQ",$J),PSGWIO,ZTSK,ZTIO,DA,HDRFLG,IO("Q") D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@" Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGWBOI 2606 printed Oct 16, 2024@17:39:49 Page 2
PSGWBOI ;BHAM ISC/CML-Print Backorder Report by Specific Item (Single or Multiple) ; 19 Mar 93 / 8:24 AM
+1 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
SINGLE ;ENTRY POINT FOR SINGLE ITEM
+1 WRITE !
KILL DIC,^TMP("PSGWQ",$JOB)
SET DIC="^PSI(58.3,"
SET DIC(0)="QEAOM"
DO ^DIC
KILL DIC
if Y<0
GOTO QUIT
SET BODA=+Y
SET DRGDA=$PIECE(Y,"^",2)
GOTO START
MULTI ;ENTRY POINT FOR MULTIPLE ITEMS
+1 WRITE !
KILL DIC,^TMP("PSGWQ",$JOB)
SET DIC="^PSI(58.3,"
SET DIC(0)="QEAOM"
FOR JJ=0:0
DO ^DIC
if Y<0
QUIT
SET ^TMP("PSGWQ",$JOB,+Y)=$PIECE(Y,"^",2)
+2 IF X="^"!('$DATA(^TMP("PSGWQ",$JOB)))
GOTO QUIT
START 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^PSGWBOI"
SET ZTDESC="Compile data for ITEM Backorder report"
SET ZTSAVE("PSGWIO")=""
+2 IF $TEST
if $DATA(^TMP("PSGWQ",$JOB))
SET ZTSAVE("^TMP(""PSGWQ"",$J,")=""
if $DATA(BODA)
SET ZTSAVE("BODA")=""
if $DATA(DRGDA)
SET ZTSAVE("DRGDA")=""
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO QUIT
+3 USE IO
+4 ;
ENQ ;ENTRY POINT WHEN QUEUED
+1 KILL ^TMP("PSGWBOI",$JOB)
IF $DATA(BODA)
IF $DATA(DRGDA)
SET HDRFLG="S"
DO BUILD
if $DATA(ZTQUEUED)
GOTO PRTQUE
GOTO PRT1^PSGWBOIP
+2 IF $DATA(^TMP("PSGWQ",$JOB))
SET HDRFLG="M"
FOR BODA=0:0
SET BODA=$ORDER(^TMP("PSGWQ",$JOB,BODA))
if 'BODA&($DATA(ZTQUEUED))
GOTO PRTQUE
if 'BODA
GOTO PRT1^PSGWBOIP
SET DRGDA=$PIECE(^(BODA),"^")
DO BUILD
+3 ;
BUILD ;
+1 if '$DATA(^PSDRUG(DRGDA,0))
QUIT
SET DNM=$SELECT($PIECE(^(0),"^")]"":$PIECE(^(0),"^"),1:"UNKNOWN")
+2 IF '$ORDER(^PSI(58.3,BODA,0))
SET ^TMP("PSGWBOI",$JOB,DNM,"ZZZ","ZZZ")=""
QUIT
+3 FOR AOU=0:0
SET AOU=$ORDER(^PSI(58.3,BODA,1,AOU))
if 'AOU
QUIT
IF $DATA(^(AOU,0))
DO AOUCHK
FOR BO=0:0
SET BO=$ORDER(^PSI(58.3,BODA,1,AOU,1,BO))
if 'BO
QUIT
IF $DATA(^(BO,0))
SET QQ=^(0)
DO SETGL
+4 QUIT
AOUCHK ;
+1 IF '$ORDER(^PSI(58.3,BODA,1,AOU,1,0))
SET ^TMP("PSGWBOI",$JOB,DNM,"ZZZ","ZZZ")=""
+2 QUIT
SETGL ;
+1 SET BODT=$PIECE(QQ,"^")
SET CURBO=$SELECT($PIECE(QQ,"^",5)="":$PIECE(QQ,"^",2),1:0)
+2 SET ANM=$SELECT($DATA(^PSI(58.1,AOU,0)):$PIECE(^(0),"^"),1:"AOU NAME MISSING")
IF CURBO>0
IF $DATA(^PSI(58.1,AOU,"I"))
IF ^("I")
IF ^("I")'>DT
SET ANM=ANM_" **"
+3 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)
+4 if LOC=""
SET LOC="UNKNOWN"
SET ^TMP("PSGWBOI",$JOB,DNM,ANM,BODT)=LOC_"^"_CURBO
+5 QUIT
+6 ;
PRTQUE ;
+1 KILL ZTSAVE,ZTIO
SET ZTIO=PSGWIO
SET ZTRTN="PRT1^PSGWBOIP"
SET ZTDESC="Print Data for Backorder Item List"
SET ZTDTH=$HOROLOG
SET ZTSAVE("^TMP(""PSGWBOI"",$J,")=""
SET ZTSAVE("HDRFLG")=""
+2 DO ^%ZTLOAD
KILL ^TMP("PSGWQ",$JOB)
QUIT ;
+1 KILL %DT,%,%H,%I,BO,BODA,BODT,CURBO,DIC,DNM,DRGDA,ITMDA,JJ,LOC,TOT,AOU,ANM,HDT,INACT,LL,LN,LNS,QQ,PG,X,Y
+2 KILL ^TMP("PSGWBOI",$JOB),^TMP("PSGWQ",$JOB),PSGWIO,ZTSK,ZTIO,DA,HDRFLG,IO("Q")
DO ^%ZISC
+3 if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT