source: FOIAVistA/trunk/r/DIETETICS-FH/FHNUT.m@ 1590

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

initial load of FOIAVistA 6/30/08 version

File size: 1.9 KB
Line 
1FHNUT ; HISC/NCA - Read in the and Calculate 100 Grams ;2/23/00 12:38
2 ;;5.5;DIETETICS;;Jan 28, 2005
3EN1 ; Enter Data
4 K DIC S FHX1=0,DIC="^FHNU(",DIC(0)="EMZ"
5 R !!,"Food Nutrient Name: ",TIT:DTIME G:'$T!("^"[TIT) KIL I TIT'?.ANP W *7," ??" G EN1
6 S DIC("S")="I $E($P(^(0),U,1),1)'=""*"""
7 S X=TIT D ^DIC K DIC G:U[X!($D(DTOUT)) EN1 I Y<1 G:TIT["?" EN1 D ADD G KIL:'FHX1,R2
8 S FHX1=+Y I $P($G(^FHNU(FHX1,0)),"^",6)="N" W !!," USDA Handbook Values Not Editable" Q
9R2 W !!,"Portion Size: " R X:DTIME G:'$T!("^"[X) KIL
10 I X'?.N.1".".N!(X<0)!(X>9999) W *7,!,"Enter the gram Portion Size.",!,"Enter a number From 1-9999." G R2
11 S POR=X
12STOR K A S ANS="" F L=1:1:66 S A(L)=""
13 F K=1:1:34 S Y=$T(COM+K^FHNU6),Z1=$P(Y,";",3) G:ANS="^" KIL D:Z1 CALC
14 F K=35:1:70 S Y=$T(COM+K^FHNU6),Z1=$P(Y,";",3) G:ANS="^" KIL D:Z1 CALC
15 S (Z1,Z2,Z3,Z4)="" S $P(^FHNU(FHX1,0),"^",4)=POR F K=1:1:20 S $P(Z1,"^",K)=A(K)
16 F K=21:1:38 S $P(Z2,"^",K-20)=A(K)
17 F K=39:1:56 S $P(Z3,"^",K-38)=A(K)
18 F K=57:1:66 S $P(Z4,"^",K-56)=A(K)
19 S ^FHNU(FHX1,1)=Z1,^(2)=Z2 S:Z3'="" ^FHNU(FHX1,3)=Z3 S:Z4'="" ^FHNU(FHX1,4)=Z4
20 G EN1
21KIL G KILL^XUSCLEAN
22ADD ; Add the new entry
23 W !!,"ADD ",TIT," as a New Entry? Y// " R X:DTIME Q:'$T!(X="^") S:X="" X="Y" D TR^FH I $P("YES",X,1)'="",$P("NO",X,1)'="" W *7," Answer YES or NO" G ADD
24 S X=$E(X,1) Q:X="N"
25 K DIC,DD,DO,X S (DIC,DIE)="^FHNU(",DIC(0)="L",DLAYGO=112
26A L +^FHNU(0) S DA=$P(^FHNU(0),"^",3)+1 I $D(^FHNU(DA)) S $P(^FHNU(0),"^",3)=DA L -^FHNU(0) G A
27 S X=TIT D FILE^DICN L -^FHNU(0) S FHX1=+Y K DIC,DLAYGO
28 S DA=+Y,DR=".01;2;4:5;7;98;99" S:$D(^XUSEC("FHMGR",DUZ)) DIDEL=112 D ^DIE S:$D(DTOUT)!($D(Y))!('$D(DA)) FHX1=0 K DA,DIE,DR,Y
29 Q
30CALC ; Read in Food Nutrient and Calculate 100 gms
31 W !,$P(Y,";",4)_": " R X:DTIME I '$T S ANS="^" Q
32 I X["^" W *7," Required Field." G CALC
33 I X'?.N.1".".N!(X<0)!(X>99999) W *7," Enter a number from 0-99999" G CALC
34 I X'="" S DEC=$S(Z1>64:2,1:3),A(Z1)=X/POR*100,A(Z1)=$S(A(Z1):+$J(A(Z1),0,DEC),1:0) W "... ",A(Z1)
35 Q
Note: See TracBrowser for help on using the repository browser.