source: WorldVistAEHR/trunk/r/AUTO_REPLENISHMENT_WARD_STOCK-PSGW/PSGWNU.m@ 1154

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

initial load of WorldVistAEHR

File size: 3.1 KB
RevLine 
[613]1PSGWNU ;BHAM ISC/PTD,CML-Print Drugs (Items) with NO Usage for Selected Date Range ; 19 Mar 93 / 8:31 AM
2 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
3BDT S %DT="AEX",%DT("A")="BEGINNING date for report: " D ^%DT K %DT G:Y<0 END^PSGWNU1 S BDT=Y
4EDT S %DT="AEX",%DT(0)=BDT,%DT("A")="ENDING date for report: " D ^%DT K %DT G:Y<0 END^PSGWNU1 S EDT=Y
5 D SEL^PSGWUTL1 G:'$D(SEL) END^PSGWNU1 I SEL="I" F JJ=0:0 S JJ=$O(AOULP(JJ)) Q:'JJ I $S('$D(^PSI(58.1,JJ,"I")):0,'^("I"):0,^("I")>DT:0,1:1) K AOULP(JJ)
6 G:SEL="I" EN
7ASKAOU F JJ=0:0 S DIC="^PSI(58.1,",DIC(0)="QEAM",DIC("S")="I $S('$D(^(""I"")):1,'^(""I""):1,^(""I"")>DT:1,1:0)" D ^DIC K DIC Q:Y<0 S AOULP(+Y)=""
8 I '$D(AOULP)&(X'="^ALL") G END^PSGWNU1
9 I X="^ALL" F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) Q:'AOU I $S('$D(^PSI(58.1,AOU,"I")):1,'^("I"):1,^("I")>DT:1,1:0) S AOULP(AOU)=""
10EN G:'$D(AOULP) END^PSGWNU1 W !!,"The right margin for this report is 80.",!,"You may queue the report to print at a later time.",!!
11DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END^PSGWNU1
12 I $D(IO("Q")) K IO("Q") S PSGWIO=ION,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="ENQ^PSGWNU",ZTDESC="Compile Zero Usage" S:$D(AOULP) ZTSAVE("AOULP(")="" F G="BDT","EDT","AOU","PSGWIO","SEL","IGDA" S:$D(@G) ZTSAVE(G)=""
13 I D ^%ZTLOAD,HOME^%ZIS K ZTSK G END^PSGWNU1
14 U IO
15 ;
16ENQ ;ENTRY POINT WHEN QUEUED
17 K ^TMP("PSGWNU",$J) S AOU=""
18AOU S AOU=$O(AOULP(AOU)) G:('AOU)&($D(ZTQUEUED)) PRTQUE G:'AOU ^PSGWNU1
19DRUG ;LOOP THROUGH DRUGS FOR AOU
20 S DRGDA=0
21DRGLP S DRGDA=$O(^PSI(58.1,AOU,1,DRGDA)) G:'DRGDA AOU S DRGNM=$P(^PSI(58.1,AOU,1,DRGDA,0),"^")
22 I '$O(^PSDRUG(DRGNM,0)) S DIK="^PSI(58.1,"_AOU_",1,",DA=DRGDA,DA(1)=AOU D ^DIK K DIK G DRGLP
23 S DRGNAME=$P(^PSDRUG(DRGNM,0),"^")
24INACT I $P(^PSI(58.1,AOU,1,DRGDA,0),"^",10)="Y",$P(^(0),"^",3)="" S $P(^(0),"^",10)=""
25 I $P(^PSI(58.1,AOU,1,DRGDA,0),"^",3)'="" G DRGLP
26 ;
27AR ;AUTOMATIC REPLENISHMENT INVENTORIES
28 S (DRGQD,INVDA)=0,AR=""
29INVLP S INVDA=$O(^PSI(58.1,AOU,1,DRGDA,1,INVDA)) G:'INVDA OD S ARDT=$S($D(^PSI(58.19,INVDA,0)):$P(^(0),"^"),1:"")
30 I 'ARDT,'$D(^PSI(58.19,INVDA,0)) S DIE="^PSI(58.1,AOU,1,DRGDA,1,",DA=INVDA,DA(1)=DRGDA,DA(2)=AOU,DR=".01///@" D ^DIE K DIE G INVLP
31 S QD=$P(^PSI(58.1,AOU,1,DRGDA,1,INVDA,0),"^",5) I (QD'="")&(QD>0)&(ARDT>AR) S AR=ARDT
32 I (ARDT'<BDT)&(ARDT'>EDT) S DRGQD=DRGQD+QD
33 G INVLP
34 ;
35OD ;ON DEMAND REQUESTS
36 S ODA=0,OD=""
37ODLP S ODA=$O(^PSI(58.1,AOU,1,DRGDA,5,ODA)) G:'ODA RET S ODT=$P($P(^PSI(58.1,AOU,1,DRGDA,5,ODA,0),"^"),".")
38 S QD=$P(^PSI(58.1,AOU,1,DRGDA,5,ODA,0),"^",2) I (QD'="")&(QD>0)&(ODT>OD) S OD=ODT
39 I (ODT'<BDT)&(ODT'>EDT) S DRGQD=DRGQD+QD
40 G ODLP
41 ;
42RET ;RETURNS
43 S RETDT=0,RFLG="N"
44RETLP S RETDT=$O(^PSI(58.1,AOU,1,DRGDA,3,RETDT)) G:'RETDT SETGL
45 I (RETDT'<BDT)&(RETDT'>EDT) S QD=$P(^PSI(58.1,AOU,1,DRGDA,3,RETDT,0),"^",2),DRGQD=DRGQD-QD,RFLG="Y"
46 G RETLP
47 ;
48SETGL S:DRGQD<1 ^TMP("PSGWNU",$J,AOU,DRGNAME)=AR_"^"_OD_"^"_RFLG_"^"_DRGQD_"^"_DRGNM G DRGLP
49 ;
50PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
51 K ZTSAVE,ZTIO S ZTIO=PSGWIO,ZTRTN="^PSGWNU1",ZTDESC="Print Zero Usage",ZTDTH=$H,ZTSAVE("^TMP(""PSGWNU"",$J,")="" F G="BDT","EDT","AOU","SEL","IGDA" S:$D(@G) ZTSAVE(G)=""
52 D ^%ZTLOAD K ^TMP("PSGWNU",$J) G END^PSGWNU1
53 ;
Note: See TracBrowser for help on using the repository browser.