source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCPRSOH.m@ 810

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

initial load of WorldVistAEHR

File size: 4.5 KB
RevLine 
[613]1PRCPRSOH ;WISC/RFJ/DAP/VAC-days of stock on hand report ; 10/19/06 9:09am
2 ;;5.1;IFCAP;**84,83,98**;Oct 20, 2000;Build 37
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ;*83 Routine PRCPLO associated with PRC*5.1*83 is a modified copy of
6 ;this routine and any changes made to this routine should also be
7 ;considered for that routine as well.
8 ;
9 ;*98 Modified to show if Standard, On-Demand or Both
10 ;
11 D ^PRCPUSEL Q:'$G(PRCP("I"))
12 N DATEEND,DATEENDD,DATESTRD,DATESTRT,DAYSLEFT,DIR,GROUPALL,PRCPDAYS,PRCPEND,PRCPSTRT,PRCPTYPE,TOTALDAY,X,X1,X2,Y
13 N ODIFLG,ODITEM,USEFLG
14 K X S X(1)="The Days Of Stock On Hand Report will print a list of items which have stock on hand less than or greater than a specified number of days."
15 D DISPLAY^PRCPUX2(40,79,.X)
16 K X S X(1)="Select the date range which should be used for calculating the daily usage. *** Select by month & year only. ***" D DISPLAY^PRCPUX2(2,40,.X)
17 D MONTHSEL^PRCPURS2 I '$G(DATEEND) Q
18 S X1=DATEEND,X2=DATESTRT D ^%DTC S TOTALDAY=X+1
19 S Y=DATEEND D DD^%DT S DATEENDD=Y,Y=DATESTRT D DD^%DT S DATESTRD=Y
20 W !?5,"-- TOTAL NUMBER OF DAYS: ",TOTALDAY
21 ; select greater or less
22 K X S X(1)="Select the type of report: less than a specified number of days or greater than a specified number of days." D DISPLAY^PRCPUX2(2,40,.X)
23 S DIR(0)="S^1:LESS;2:GREATER",DIR("A")="Print items with GREATER or LESS than 'X' days stock on hand",DIR("B")="LESS"
24 D ^DIR S PRCPTYPE=+Y I 'PRCPTYPE Q
25 ; select days
26 K X S X(1)="Select the number of days which the current stock on hand should be "_$S(PRCPTYPE=1:"LESS than",1:"GREATER than")_"." D DISPLAY^PRCPUX2(2,40,.X)
27 S DIR(0)="N^1:365",DIR("A")="Print items with stock on hand "_$S(PRCPTYPE=1:"less than",1:"greater than")_" DAYS",DIR("B")=30
28 D ^DIR S PRCPDAYS=+Y I 'PRCPDAYS Q
29 ; whse sort
30 I PRCP("DPTYPE")="W" D I '$D(PRCPSTRT) Q
31 . K X S X(1)="Select the range of NSNs to display" D DISPLAY^PRCPUX2(2,40,.X)
32 . D NSNSEL^PRCPURS0
33 ; prim/seco sort
34 I PRCP("DPTYPE")'="W" D I '$G(GROUPALL),'$O(^TMP($J,"PRCPURS1","YES",0)) W !,"*** NO GROUP CATEGORIES SELECTED !" Q
35 . K X S X(1)="Select the Group Categories to display" D DISPLAY^PRCPUX2(2,40,.X)
36 . D GROUPSEL^PRCPURS1(PRCP("I"))
37 ;
38ODIFLG ;*98 Set flag for Standard, On-Demand item or Both
39 S ODIFLG="W"
40 I PRCP("DPTYPE")'="W" S ODIFLG=$$ODIPROM^PRCPUX2(0)
41 Q:ODIFLG=0
42 ;
43 S %ZIS="Q" D ^%ZIS Q:POP I $D(IO("Q")) D Q
44 . S ZTDESC="Days of Stock On Hand Report",ZTRTN="DQ^PRCPRSOH"
45 . S ZTSAVE("^TMP($J,""PRCPURS1"",")=""
46 . S ZTSAVE("DATE*")="",ZTSAVE("GROUP*")="",ZTSAVE("PRCP*")="",ZTSAVE("TOTALDAY")="",ZTSAVE("ZTREQ")="@",ZTSAVE("O*")="",ZTSAVE("U*")=""
47 . D ^%ZTLOAD
48 W !!,"<*> please wait <*>"
49DQ ; queue starts here
50 N AVERAGE,DATE,GROUP,GROUPNM,ITEMDA,ITEMDATA,NSN,ONHAND,TOTAL,X,Y
51 K ^TMP($J,"PRCPRSOH")
52 S ITEMDA=0 F S ITEMDA=$O(^PRCP(445,PRCP("I"),1,ITEMDA)) Q:'ITEMDA S ITEMDATA=$G(^(ITEMDA,0)) I ITEMDATA'="" D
53 .; Select item based on selection criteria
54 . S USEFLG="Y"
55 . I PRCP("DPTYPE")'="W" D
56 . . S ODITEM=$$ODITEM^PRCPUX2(PRCP("I"),ITEMDA)
57 . . I ODIFLG=1&(ODITEM="Y") S USEFLG="N"
58 . . I ODIFLG=2&(ODITEM'="Y") S USEFLG="N"
59 . . I ODIFLG=3 S USEFLG="Y"
60 . I USEFLG="N" Q
61 . I $$REUSABLE^PRCPU441(ITEMDA) Q
62 . ; calculate total usage between dates
63 . S DATE=$E(DATESTRT,1,5)-.01,TOTAL=0 F S DATE=$O(^PRCP(445,PRCP("I"),1,ITEMDA,2,DATE)) Q:'DATE!(DATE>$E(DATEEND,1,5)) S TOTAL=TOTAL+$P($G(^(DATE,0)),"^",2)
64 . S AVERAGE=$J(TOTAL/TOTALDAY,0,2),ONHAND=$P(ITEMDATA,"^",7)+$P(ITEMDATA,"^",19)
65 . S DAYSLEFT=$S('AVERAGE&(ONHAND):9999999,'AVERAGE:0,1:ONHAND/AVERAGE\1)
66 . I PRCPTYPE=1,DAYSLEFT'<PRCPDAYS Q
67 . I PRCPTYPE=2,DAYSLEFT'>PRCPDAYS Q
68 . ; sort for whse
69 . I PRCP("DPTYPE")="W" D Q
70 . . S NSN=$$NSN^PRCPUX1(ITEMDA) S:NSN="" NSN=" "
71 . . I $E(NSN,1,$L(PRCPSTRT))'=PRCPSTRT,$E(NSN,1,$L(PRCPEND))'=PRCPEND I NSN']PRCPSTRT!(PRCPEND']NSN) Q
72 . . S ^TMP($J,"PRCPRSOH",NSN,ITEMDA)=TOTAL_"^"_AVERAGE_"^"_ONHAND_"^"_$P(DAYSLEFT,".")_"^"_$P(ITEMDATA,"^",27)
73 . ; sort for primary and secondary
74 . S GROUP=+$P(ITEMDATA,"^",21)
75 . I 'GROUP,'$G(GROUPALL) Q
76 . I $G(GROUPALL),$D(^TMP($J,"PRCPURS1","NO",GROUP)) Q
77 . I '$G(GROUPALL),'$D(^TMP($J,"PRCPURS1","YES",GROUP)) Q
78 . S GROUPNM=$$GROUPNM^PRCPEGRP(GROUP)
79 . I GROUPNM'="" S GROUPNM=$E(GROUPNM,1,20)_" (#"_GROUP_")"
80 . S:GROUPNM="" GROUPNM=" "
81 . S ^TMP($J,"PRCPRSOH",GROUPNM,$E($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,15),ITEMDA)=TOTAL_"^"_AVERAGE_"^"_ONHAND_"^"_$P(DAYSLEFT,".")_"^"_$P(ITEMDATA,"^",27)
82 ;
83 D PRINT^PRCPRSO1
84 K ^TMP($J,"PRCPURS1"),^TMP($J,"PRCPRSOH")
85 D ^%ZISC
86 Q
Note: See TracBrowser for help on using the repository browser.