1 | PSGWCPA ;BHAM ISC/PTD,CML-Cost Per AOU for Selected Date Range ; 03 Sep 93 / 12:07 PM
|
---|
2 | ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
|
---|
3 | W !?5,"Before printing this report, be sure accurate data exists for drug cost.",!?5,"Use ""Prepare AMIS Data"": ""Enter AMIS Data for All Drugs/All AOUs"".",!!
|
---|
4 | BDT S %DT="AEX",%DT("A")="BEGINNING date for report: " D ^%DT K %DT G:Y<0 END^PSGWCPA1 S BDT=Y
|
---|
5 | EDT S %DT="AEX",%DT(0)=BDT,%DT("A")="ENDING date for report: " D ^%DT K %DT G:Y<0 END^PSGWCPA1 S EDT=Y
|
---|
6 | D SEL^PSGWUTL1 G:'$D(SEL) END^PSGWCPA1 G:SEL="I" AOUCNT
|
---|
7 | ASKAOU F JJ=0:0 S DIC="^PSI(58.1,",DIC(0)="QEAM" D ^DIC K DIC Q:Y<0 S AOULP(+Y)=""
|
---|
8 | I '$D(AOULP)&(X'="^ALL") G END^PSGWCPA1
|
---|
9 | I X="^ALL" F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) Q:'AOU S AOULP(AOU)=""
|
---|
10 | AOUCNT G:'$D(AOULP) END^PSGWCPA1 S AOUCNT=0 F JJ=0:0 S JJ=$O(AOULP(JJ)) Q:'JJ S AOUCNT=AOUCNT+1
|
---|
11 | W !!,"Do you want to print:",!?5,"(1) A complete report",!?5,"(2) Totals and Summaries only"
|
---|
12 | ASKPRT R !!,"Enter '1' or '2': ",FLG:DTIME S:'$T FLG="^" G:"^"[FLG END^PSGWCPA1
|
---|
13 | I FLG?1."?"!((FLG'=1)&(FLG'=2)) W *7,!!,"Enter '1' to print a complete report including all items in the AOU.",!,"Enter '2' to print only the totals for the AOU(s) and Cost Summaries." G ASKPRT
|
---|
14 | W !!,"The right margin for this report is 80.",!,"You may queue the report to print at a later time.",!!
|
---|
15 | DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END^PSGWCPA1
|
---|
16 | I $D(IO("Q")) K IO("Q") S PSGWIO=ION,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="ENQ^PSGWCPA",ZTDESC="Compile Cost per AOU" S:$D(AOULP) ZTSAVE("AOULP(")="" F G="BDT","EDT","FLG","PSGWIO","AOUCNT","SEL","IGDA" S:$D(@G) ZTSAVE(G)=""
|
---|
17 | I D ^%ZTLOAD,HOME^%ZIS K ZTSK G END^PSGWCPA1
|
---|
18 | U IO
|
---|
19 | ;
|
---|
20 | ENQ ;ENTRY POINT WHEN QUEUED
|
---|
21 | ;CREATE ARRAY OF INVENTORY NUMBERS THAT FALL IN DATE RANGE.
|
---|
22 | K ^TMP("PSGWCPA",$J) S (INVN,AOU)=0
|
---|
23 | F J=0:0 S INVN=$O(^PSI(58.19,INVN)) Q:'INVN S INVDT=$P($P(^PSI(58.19,INVN,0),"^"),".") I (INVDT'<BDT)&(INVDT'>EDT) S ^TMP("PSGWCPA",$J,"INV",INVN)=""
|
---|
24 | AOU S AOU=$O(AOULP(AOU)) G:('AOU)&($D(ZTQUEUED)) PRTQUE G:'AOU EN1^PSGWCPA1
|
---|
25 | DRUG ;LOOP THROUGH DRUGS FOR AOU
|
---|
26 | S DRGDA=0
|
---|
27 | DRGLP S DRGDA=$O(^PSI(58.1,AOU,1,DRGDA)) G:'DRGDA AOU S DRGNM=$P(^PSI(58.1,AOU,1,DRGDA,0),"^"),DRGNAME=$P(^PSDRUG(DRGNM,0),"^")
|
---|
28 | ;
|
---|
29 | AR ;AUTOMATIC REPLENISHMENT INVENTORIES
|
---|
30 | S DRGQD=0,INVDA=0
|
---|
31 | INVLP S INVDA=$O(^PSI(58.1,AOU,1,DRGDA,1,INVDA)) G:'INVDA OD
|
---|
32 | I $D(^TMP("PSGWCPA",$J,"INV",INVDA)) S QD=$P(^PSI(58.1,AOU,1,DRGDA,1,INVDA,0),"^",5),DRGQD=DRGQD+QD G INVLP
|
---|
33 | E G INVLP
|
---|
34 | ;
|
---|
35 | OD ;ON DEMAND REQUESTS
|
---|
36 | S ODA=0
|
---|
37 | ODLP 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 | I (ODT'<BDT)&(ODT'>EDT) S QD=$P(^PSI(58.1,AOU,1,DRGDA,5,ODA,0),"^",2),DRGQD=DRGQD+QD G ODLP
|
---|
39 | E G ODLP
|
---|
40 | ;
|
---|
41 | RET ;RETURNS
|
---|
42 | S RETDT=0
|
---|
43 | RETLP S RETDT=$O(^PSI(58.1,AOU,1,DRGDA,3,RETDT)) G:'RETDT CHKDTA
|
---|
44 | I (RETDT'<BDT)&(RETDT'>EDT) S QD=$P(^PSI(58.1,AOU,1,DRGDA,3,RETDT,0),"^",2),DRGQD=DRGQD-QD G RETLP
|
---|
45 | E G RETLP
|
---|
46 | ;
|
---|
47 | CHKDTA ;DETERMINE TOTAL COST FOR DRGQD OF SELECTED DRUG
|
---|
48 | G:DRGQD=0 DRGLP S INC=0 I $D(^PSDRUG(DRGNM,660)) S LOC1=^(660)
|
---|
49 | E S INC=1
|
---|
50 | I $D(^PSDRUG(DRGNM,"PSG")) S LOC2=^("PSG")
|
---|
51 | E S INC=1
|
---|
52 | I $D(LOC1),($P(LOC1,"^",6)="") S INC=1
|
---|
53 | I $D(LOC2),($P(LOC2,"^",3)="") S INC=1
|
---|
54 | COST I INC=0 S DRGCST=DRGQD*($P(LOC1,"^",6))
|
---|
55 | E S DRGCST="NO DATA"
|
---|
56 | SETGL S ^TMP("PSGWCPA",$J,AOU,DRGNAME)=DRGQD_"^"_DRGCST G DRGLP
|
---|
57 | ;
|
---|
58 | PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
|
---|
59 | K ZTSAVE,ZTIO S ZTIO=PSGWIO,ZTRTN="^PSGWCPA1",ZTDESC="Print Cost per AOU",ZTDTH=$H,ZTSAVE("^TMP(""PSGWCPA"",$J,")="" F G="BDT","EDT","FLG","AOUCNT","SEL","IGDA" S:$D(@G) ZTSAVE(G)=""
|
---|
60 | D ^%ZTLOAD K ^TMP("PSGWCPA",$J) G END^PSGWCPA1
|
---|