source: FOIAVistA/trunk/r/AUTO_REPLENISHMENT_WARD_STOCK-PSGW/PSGWBOA.m@ 1446

Last change on this file since 1446 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.8 KB
Line 
1PSGWBOA ;BHAM ISC/CML-Print Backorder Report by AOU or Item (ALL Current Backorders) ; 03 Sep 93 / 12:23 PM
2 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
3 W !!,"This option will print a list of ALL Current Backorders.",!
4ASK 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
5 W !!,"Right margin for this report is 80 columns.",!,"You may queue the report to print at a later time.",!!
6DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G QUIT
7 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
8 U IO
9 ;
10ENQ ;ENTRY POINT WHEN QUEUED
11 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
12 ;
13BUILD ;
14 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
15 S DNM=$S($P(^PSDRUG(DRGDA,0),"^")]"":$P(^(0),"^"),1:"UNKNOWN")
16 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
17 Q
18SETGL ;
19 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_" **"
20 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)
21 S:LOC="" LOC="UNKNOWN" I SORT="I" S ^TMP("PSGWBOA",$J,DNM,ANM,BODT)=LOC_"^"_CB Q
22 S ^TMP("PSGWBOA",$J,ANM,DNM,BODT)=LOC_"^"_CB Q
23 ;
24PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
25 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")=""
26 D ^%ZTLOAD K ^TMP("PSGWBOA",$J) G QUIT
27PRT1 ;
28 S $P(LN,"-",81)="",PG=0,%DT="",(S1,S2,QFLG)="" S HDT=$$PSGWDT^PSGWUTL1 D HDR
29 I '$D(^TMP("PSGWBOA",$J)) W !?17,"***** NO DATA AVAILABLE FOR THIS REPORT *****" S QFLG=1 G DONE
30 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
31DONE D:'QFLG INACT I $E(IOST)'="C" W @IOF
32 I $E(IOST)="C" D:'QFLG SS^PSGWUTL1
33QUIT ;
34 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
35 K ^TMP("PSGWBOA",$J),PSGWIO,ZTSK,ZTIO,DA,DNM,ANM,HF,IO("Q") D ^%ZISC
36 S:$D(ZTQUEUED) ZTREQ="@" Q
37PRT2 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
38 Q
39DATA ;
40 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
41 S Y=$E(BODT,1,12) X ^DD("DD") W !?7,S2
42 I SORT="A" W ?53,Y,?73,$J(CB,6),!?17,LOC Q
43 W ?40,LOC,?54,Y,?73,$J(CB,6) Q
44TOT ;
45 S:S2["**" INACT=1 I S2="",'QFLG D:$Y+6>IOSL PRTCHK Q:QFLG W !?72,"-------",!?66,"TOTAL:",?72,$J(TOT,7) Q
46 Q
47HDR ;
48 S INACT=0 W:$Y @IOF S PG=PG+1
49 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
50 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
51 Q
52INACT I INACT F LNS=1:1:((IOSL-$Y)-3) W !
53 I W "** Indicates an Inactive AOU"
54 Q
55PRTCHK ;
56 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
57 D HDR Q
Note: See TracBrowser for help on using the repository browser.