source: WorldVistAEHR/trunk/r/DIETETICS-FH/FHREP1.m@ 1046

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

revised back to 6/30/08 version

File size: 4.2 KB
Line 
1FHREP1 ; HISC/NCA - Inventory Worksheet and Report ;3/9/95 08:28
2 ;;5.5;DIETETICS;;Jan 28, 2005
3EN2 ; Print the Inventory Worksheet & Report
4 S FHXX="F"
5 R !!,"Select W=Worksheet or R=Report: ",FHR:DTIME G:'$T!("^"[FHR) KIL^FHREP
6 I "wr"[FHR S X=FHR D TR^FH S FHR=X
7 I FHR'?1U!("WR"'[FHR) W *7," Enter W or R" G EN2
8E0 ; Read in Month and Year
9 D NOW^%DTC S NOW=%\1
10 K %DT W !!,"Enter Mth/Yr: "_+$E(NOW,4,5)_"/"_$E(NOW,2,3)_"// " R X:DTIME G:'$T!(X["^") KIL^FHREP
11 I X="" S X=$E(NOW,1,5)_"00"
12 D ^%DT I Y<1!($E(Y,1,5)>$E(NOW,1,5)) W *7," Answer Month and Yr as Mth/Yr or Mth Yr.",!?25," CANNOT be greater than now." G E0
13 S MTH=+$E(Y,4,5),MTH=$P("January February March April May June July August September October November December"," ",MTH),YR=$E(Y,2,3),MTH=MTH_" "_YR
14 I FHR="W" D F1^FHREP G:FHXX["^"!("^"[X) KIL^FHREP
15 I FHR="R" D D1^FHREP G:"^"[X KIL^FHREP
16E1 K IOP S %ZIS="MQ",%ZIS("B")="HOME" W ! D ^%ZIS K %ZIS,IOP G:POP KIL^FHREP
17 I $D(IO("Q")) S FHPGM="Q0^FHREP1",FHLST="FHR^FHXX^MTH^SRT" D EN2^FH G KIL^FHREP
18 U IO D Q0 D ^%ZISC K %ZIS,IOP G KIL^FHREP
19Q0 ; Process Printing worksheet or report
20 D Q1 G KIL^FHREP
21Q1 ; Loop through Ingredients
22 K ^TMP($J) S ANS="",(K,GRDTOT,OLD,SUBTOT,TOTAL,PG)=0 D NOW^%DTC S DTP=% D DTP^FH S HD=DTP S CK=1
23 F K=0:0 S K=$O(^FHING(K)) Q:K<1 S X=$P($G(^(K,0)),"^",19) I X="Y" S X=$G(^(0)) D LP S:OK ^TMP($J,P0_$S(FHXX="S":$E(L0,1,15),1:"FG"_P0),ING)=K_"^"_UP_"^"_COST_"^"_QOH_"^"_UDC_"^"_UDQ_"^"_$E(MIN,1,5)
24 S REC=0
25 S P0="" F L1=0:0 S P0=$O(^TMP($J,P0)) Q:P0=""!(ANS="^") S ING="" F L2=0:0 S ING=$O(^TMP($J,P0,ING)) Q:ING="" S XX=^(ING) D P1 Q:ANS="^"
26 I FHR="R",ANS="",SRT W !!,?55,"TOTAL: ",$J(SUBTOT,8,2)
27 I FHR="R",ANS="",'SRT D SUB W !!?49,"GRAND TOTAL: ",$J(GRDTOT,8,2)
28 Q
29LP ; Get Food Group or Storage
30 S ING=$P(X,"^",1),UP=$P(X,"^",5),COST=$P(X,"^",9),QOH=$P(X,"^",11),UDC=$P(X,"^",23),UDQ=$P(X,"^",24),MIN=$P(X,"^",25),OK=1,L0=""
31 S DTP=UDC D:DTP'="" DTP^FH S UDC=DTP,DTP=UDQ D:DTP'="" DTP^FH S UDQ=DTP
32 I FHXX="F" S P0=$P(X,"^",13) S:P0<1!(P0>6) P0=7 S:SRT&(P0'=SRT) OK=0 Q
33 S LOC=$P(X,"^",12),L0=$P($G(^FH(113.1,+LOC,0)),"^",1) S:L0="" L0="UNCLASSIFIED" S P0=$P($G(^FH(113.1,+LOC,0)),"^",3),P0=$S(P0<1:99,P0<10:"0"_P0,1:P0) S:SRT&(LOC'=SRT) OK=0
34 Q
35P1 ; Loop to print or if FHR="E" edit QOH
36 S K=$P(XX,"^",1),UP=$P(XX,"^",2),COST=$P(XX,"^",3),QOH=$P(XX,"^",4),UDC=$P(XX,"^",5),UDQ=$P(XX,"^",6),MIN=$P(XX,"^",7),REC=REC+1
37 I FHR="E" D Q
38 .W !!,"Ingredient: ",$P(^FHING(K,0),"^",1)
39 .W:UDQ'="" !?12,"QOH LAST UPDATED ON ",UDQ,!
40 .K DIE S DIE="^FHING(",DA=K
41 .S:OKAY DR="8;S:X=COST Y=""@1"";29////"_DT_";@1;10;S:X=QOH Y="""";30////"_DT
42 .S:'OKAY DR="10;S:X=QOH Y="""";30////"_DT D ^DIE S:$D(DTOUT) CK=0 S:$D(Y)!$D(DTOUT) ANS="^" K DA,DIE,DR,DTOUT,Y
43 .Q
44 D CHK Q:ANS="^"
45 D:$Y'<(IOSL-5) HD W ! Q:ANS="^"
46 I $L(ING)'>30 D
47 .W !,$J(MIN,5),?6,ING,?39,UP,?43,$J(COST,8,3)
48 .I FHR="W" W ?53,UDC,?63,$J(QOH,8,2),?73,"_____" Q
49 .W ?55,$J(QOH,8,2),?64,$J(TOTAL,8,2)
50 .Q
51 E D
52 .S L=$L($E(ING,1,30),",")
53 .S:L=1 L=L+1 W !,$J(MIN,5),?6,$P(ING,",",1,L-1),","
54 .W !?6,$P(ING,",",L,99),?39,UP,?43,$J(COST,8,3)
55 .I FHR="W" W ?53,UDC,?63,$J(QOH,8,2),?73,"_____" Q
56 .W ?55,$J(QOH,8,2),?64,$J(TOTAL,8,2)
57 .Q
58 Q
59CHK ; Check the Food Group or Storage to do Subtotal & Grandtotal
60 S P1=$S(FHXX="F":+P0,1:$E(P0,3,17))
61 I REC=1 S OLD=P1 D HDR
62 I OLD'=P1 D:FHR="R" SUB D HD
63 S OLD=P1
64 ; Calculate subtotal grand total
65 Q:FHR'="R"
66 S TOTAL=COST*QOH
67 S SUBTOT=SUBTOT+TOTAL
68 S GRDTOT=GRDTOT+TOTAL
69 Q
70SUB ; Write subtotal
71 W !!,?52,"SUBTOTAL: ",$J(SUBTOT,8,2)
72 S SUBTOT=0
73 Q
74HD ; Check for end of page
75 G:REC=1 HDR
76 I IOST?1"C".E W:$X>1 ! W *7 K DIR S DIR(0)="E" D ^DIR I 'Y S ANS="^" Q
77HDR ; Heading for the Inventory
78 W:'($E(IOST,1,2)'="C-"&'PG) @IOF S PG=PG+1
79 W !,HD,?70,"Page ",PG,!!?22,"I N V E N T O R Y " W $S(FHR="W":"W O R K S H E E T",1:"R E P O R T"),!!
80 W ?(80-$L(MTH)/2),MTH,!!
81 I FHXX="F" S P2="FOOD GROUP: "_$P("MEAT PRODUCTS^MILK PRODUCTS^FRUITS & VEGETABLES^BREADS^COMMERCIAL NUTRITION SUPPLEMENTS^MISCELLANEOUS^UNCLASSIFIED","^",+P1)
82 E S P2=P1
83 W ?(80-$L(P2)/2),P2,!!
84 I FHR="W" W !?56,"DATE",!?47,"ITEM",?56,"LAST",?66,"QOH",?74,"QOH",!,"ITEM#",?20,"NAME",?38,"U/P",?47,"COST",?55,"UPDATE",?63,"LAST MTH",?72,"CURRENT",! Q
85 W !?47,"ITEM",?58,"QOH",?67,"TOTAL",!,"ITEM#",?20,"NAME",?38,"U/P",?47,"COST",?56,"CURRENT",?68,"COST",!
86 Q
Note: See TracBrowser for help on using the repository browser.