source: FOIAVistA/trunk/r/AUTO_REPLENISHMENT_WARD_STOCK-PSGW/PSGWSC.m@ 1757

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

initial load of FOIAVistA 6/30/08 version

File size: 3.2 KB
Line 
1PSGWSC ;BHAM ISC/PTD,CML-Cost Report for Single Item for Selected Date Range ; 11 Aug 93 / 7:52 AM
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"".",!!
4BDT S %DT="AEX",%DT("A")="BEGINNING date for report: " D ^%DT K %DT G:Y<0 END^PSGWSC1 S BDT=Y
5EDT S %DT="AEX",%DT(0)=BDT,%DT("A")="ENDING date for report: " D ^%DT K %DT G:Y<0 END^PSGWSC1 S EDT=Y
6 D SEL^PSGWUTL1 G:'$D(SEL) END^PSGWSC1 G:SEL="I" AOUCNT
7ASKAOU 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^PSGWSC1
9 I X="^ALL" F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) Q:'AOU S AOULP(AOU)=""
10AOUCNT G:'$D(AOULP) END^PSGWSC1 S AOUCNT=0 F JJ=0:0 S JJ=$O(AOULP(JJ)) Q:'JJ S AOUCNT=AOUCNT+1
11ASKITEM W ! S DIC="^PSDRUG(",DIC(0)="QEAOM",DIC("A")="Select ITEM: ",DIC("S")="I $S('$D(^(""I"")):1,+^(""I"")>DT:1,1:0)" D ^DIC K DIC G:Y<0 END^PSGWSC1 S ITNAM=$P(Y,"^",2),DRGNM=$P(Y,"^")
12 S CHK=0 F JJ=0:0 S JJ=$O(AOULP(JJ)) Q:'JJ I $D(^PSI(58.1,JJ,1,"B",DRGNM)) S CHK=1 Q
13 I 'CHK W !!,*7,"This ITEM is not defined in the "_$S(AOUCNT>1:"AOUs",1:"AOU")_" you have selected!" G ASKITEM
14 W !!,"The right margin for this report is 80.",!,"You may queue the report to print at a later time.",!!
15DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END^PSGWSC1
16 I $D(IO("Q")) K IO("Q") S ZTRTN="ENQ^PSGWSC",ZTDESC="Print Cost for Single Item" S:$D(AOULP) ZTSAVE("AOULP(")="" F G="BDT","EDT","ITNAM","DRGNM","SEL","IGDA" S:$D(@G) ZTSAVE(G)=""
17 I D ^%ZTLOAD,HOME^%ZIS K ZTSK S QFLG=1 G DONE^PSGWSC1
18 U IO
19 ;
20ENQ ;ENTRY POINT WHEN QUEUED
21 ;CREATE ARRAY OF INVENTORY NUMBERS THAT FALL IN DATE RANGE.
22 K ^TMP("PSGWSC",$J),^TMP("PSGWINV",$J) S INVN=0,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("PSGWINV",$J,INVN)=""
24AOU S AOU=$O(AOULP(AOU)) G:'AOU ^PSGWSC1
25DRUG S DRGDA=$O(^PSI(58.1,AOU,1,"B",DRGNM,0)) G:'DRGDA AOU
26 ;
27AR ;AUTOMATIC REPLENISHMENT INVENTORIES
28 S DRGQD=0 G:'$O(^PSI(58.1,AOU,1,DRGDA,1,0)) OD S INVDA=0
29INVLP S INVDA=$O(^PSI(58.1,AOU,1,DRGDA,1,INVDA)) G:'INVDA OD
30 I $D(^TMP("PSGWINV",$J,INVDA)) S QD=$P(^PSI(58.1,AOU,1,DRGDA,1,INVDA,0),"^",5),DRGQD=DRGQD+QD G INVLP
31 E G INVLP
32 ;
33OD ;ON DEMAND REQUESTS
34 G:'$O(^PSI(58.1,AOU,1,DRGDA,5,0)) RET S ODA=0
35ODLP 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),"^"),".")
36 I (ODT'<BDT)&(ODT'>EDT) S QD=$P(^PSI(58.1,AOU,1,DRGDA,5,ODA,0),"^",2),DRGQD=DRGQD+QD G ODLP
37 E G ODLP
38 ;
39RET ;RETURNS
40 G:'$O(^PSI(58.1,AOU,1,DRGDA,3,0)) CHKDTA S RETDT=0
41RETLP S RETDT=$O(^PSI(58.1,AOU,1,DRGDA,3,RETDT)) G:'RETDT CHKDTA
42 I (RETDT'<BDT)&(RETDT'>EDT) S QD=$P(^PSI(58.1,AOU,1,DRGDA,3,RETDT,0),"^",2),DRGQD=DRGQD-QD G RETLP
43 E G RETLP
44 ;
45CHKDTA ;DETERMINE TOTAL COST FOR DRGQD OF SELECTED DRUG
46 G:DRGQD=0 AOU S INC=0 I $D(^PSDRUG(DRGNM,660)) S LOC1=^(660)
47 E S INC=1
48 I $D(^PSDRUG(DRGNM,"PSG")) S LOC2=^("PSG")
49 E S INC=1
50 I $D(LOC1),($P(LOC1,"^",6)="") S INC=1
51 I $D(LOC2),($P(LOC2,"^",3)="") S INC=1
52COST I INC=0 S DRGCST=DRGQD*($P(LOC1,"^",6))
53 E S DRGCST="NO DATA"
54SETGL S ^TMP("PSGWSC",$J,AOU)=DRGQD_"^"_DRGCST G AOU
55 ;
Note: See TracBrowser for help on using the repository browser.