VistA-WorldVistAEHR/r/AUTO_REPLENISHMENT_WARD_STO.../PSGWBOI.m

40 lines
2.5 KiB
Mathematica

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