source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCPRCTA.m@ 1544

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

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1PRCPRCTA ;WISC/RFJ-cost trend analysis (option, whse) ;26 May 93
2 ;;5.1;IFCAP;;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 D ^PRCPUSEL Q:'$G(PRCP("I"))
5 I PRCP("DPTYPE")="P" D PRIMARY^PRCPRCTP Q
6 ;
7 ; cost trend analysis for whse
8 N %,%H,%I,DATEEND,DATESTRT,PRCPEND,PRCPSTRT,PRCPSUMM,X,Y
9 K X S X(1)="The Cost Trend Analysis Report will compute the average item cost for the specified period based on the monthly opening balance last receipt cost."
10 S X(2)="It will compare the computed average item cost with the current monthly opening balance average cost and display the percent increase or decrease change."
11 S X(3)="The report will sort Warehouse inventory items by NSN."
12 D DISPLAY^PRCPUX2(40,79,.X)
13 K X S X(1)="Enter the date range (month-year) for computing the average item cost." D DISPLAY^PRCPUX2(2,40,.X)
14 D MONTHSEL^PRCPURS2 I '$G(DATEEND) Q
15 K X S X(1)="Select the range of NSNs to display." W ! D DISPLAY^PRCPUX2(2,40,.X)
16 D NSNSEL^PRCPURS0 I '$D(PRCPSTRT) Q
17 S PRCPSUMM=$$SUMMARY^PRCPURS0 I PRCPSUMM<0 Q
18 W ! S %ZIS="Q" D ^%ZIS Q:POP I $D(IO("Q")) D D ^%ZTLOAD K IO("Q"),ZTSK Q
19 . S ZTDESC="Cost Trend Analysis",ZTRTN="DQ^PRCPRCTA"
20 . S ZTSAVE("PRCP*")="",ZTSAVE("DATE*")="",ZTSAVE("ZTREQ")="@"
21 W !!,"<*> please wait <*>"
22DQ ; queue starts here
23 N AVG,CHANGE,COUNT,CURDT,CURRENT,D,DATA,DATE,DATEEDT,DATESDT,HDR,ITEMDA,ITEMDATA,NOW,NSN,PAGE,PRCPFLAG,SCREEN,TOTAL
24 K ^TMP($J,"PRCPRCTA")
25 S ITEMDA=0 F S ITEMDA=$O(^PRCP(445,PRCP("I"),1,ITEMDA)) Q:'ITEMDA D
26 . S NSN=$$NSN^PRCPUX1(ITEMDA) S:NSN="" NSN=" "
27 . I $E(NSN,1,$L(PRCPSTRT))'=PRCPSTRT,$E(NSN,1,$L(PRCPEND))'=PRCPEND I NSN']PRCPSTRT!(PRCPEND']NSN) Q
28 . S (COUNT,TOTAL)=0
29 . S DATE=$E(DATESTRT,1,5) F D Q:DATE>$E(DATEEND,1,5)
30 . . S D=$G(^PRCP(445.1,PRCP("I"),1,ITEMDA,1,DATE,0))
31 . . S ^TMP($J,"PRCPRCTA",NSN,ITEMDA,DATE)=+$P(D,"^",7)
32 . . I $P(D,"^",7) S COUNT=COUNT+1,TOTAL=TOTAL+$P(D,"^",7)
33 . . S X1=DATE_"00",X2=40 D C^%DTC S DATE=$E(X,1,5)
34 . S AVG=$S(COUNT=0:0,1:$J(TOTAL/COUNT,0,3)),CURRENT=+$P($G(^PRCP(445.1,PRCP("I"),1,ITEMDA,1,$E(DT,1,5),0)),"^",7),CHANGE=$S(AVG=0:"***.**",1:(CURRENT-AVG)/AVG*100)
35 . S ^TMP($J,"PRCPRCTA",NSN,ITEMDA,"TOTAL")=AVG_"^"_CURRENT_"^"_CHANGE
36 ; print report
37 D NOW^%DTC S Y=% D DD^%DT S NOW=Y,Y=$E(DT,1,5)_"00" D DD^%DT S CURDT=Y
38 S Y=$E(DATESTRT,1,5)_"00" D DD^%DT S DATESDT=Y,Y=$E(DATEEND,1,5)_"00" D DD^%DT S DATEEDT=Y
39 S PAGE=1,SCREEN=$$SCRPAUSE^PRCPUREP U IO D H
40 S NSN="" F S NSN=$O(^TMP($J,"PRCPRCTA",NSN)) Q:NSN=""!($G(PRCPFLAG)) S ITEMDA=0 F S ITEMDA=$O(^TMP($J,"PRCPRCTA",NSN,ITEMDA)) Q:'ITEMDA!($G(PRCPFLAG)) D
41 . I $G(ZTQUEUED),$$S^%ZTLOAD S PRCPFLAG=1 W !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>" Q
42 . I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
43 . S ITEMDATA=$G(^PRCP(445,PRCP("I"),1,ITEMDA,0))
44 . W !!,$TR(NSN,"-"),?15,$E($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,18),?34,$J(ITEMDA,6),$J($$UNIT^PRCPUX1(PRCP("I"),ITEMDA,"/"),10)
45 . S D=$G(^TMP($J,"PRCPRCTA",NSN,ITEMDA,"TOTAL"))
46 . W $J($P(D,"^"),10,2),$J($P(D,"^",2),10,2),$J($P(D,"^",3),10,2)
47 . I $G(PRCPSUMM) Q
48 . S DATE=0 F D Q:'DATE!($G(PRCPFLAG))
49 . . S (DATA,HDR)=""
50 . . F COUNT=1:1:9 S DATE=$O(^TMP($J,"PRCPRCTA",NSN,ITEMDA,DATE)) Q:'DATE S D=^(DATE) D
51 . . . S %=$P("Jan^Feb^Mar^Apr^May^Jun^Jul^Aug^Sep^Oct^Nov^Dec","^",+$E(DATE,4,5))_" "_$E(DATE,2,3),HDR=HDR_$J(%,8)
52 . . . S DATA=DATA_$J(D,8,2)
53 . . I DATA'="" W !?5,HDR,!?5,DATA
54 . . I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
55 I '$G(PRCPFLAG) D END^PRCPUREP
56 D ^%ZISC K ^TMP($J,"PRCPRCTA")
57 Q
58 ;
59H S %=NOW_" PAGE "_PAGE,PAGE=PAGE+1 I PAGE'=2!(SCREEN) W @IOF
60 W $C(13),"COST TREND ANALYSIS FOR: ",$E(PRCP("IN"),1,20),?(80-$L(%)),%
61 W !?5,"CUM AVG CALCULATED FROM DATE RANGE: ",DATESDT," TO ",DATEEDT
62 S %="",$P(%,"-",81)="" W !,"NSN",?15,"DESCRIPTION",?38,"MI",$J("UNIT/IS",10),$J("CUM AVG",10),$J(CURDT,10),$J("%CHANGE",10),!,%
63 Q
Note: See TracBrowser for help on using the repository browser.