FHUD112 ;SLC/GDU - UPDATE FILE #112 TO CURRENT USDA NUTRITIONAL DATABASE
;;5.5;DIETETICS;**26**;Jan 28, 2005;Build 17
;
;USDA National Nutrient Database for Standard Reference, Release 23
;Data to update the FOOD NUTRIENTS FILE, #112
;Routine is not intended to be called by name alone.
Q
EN ;Entry point of this routine
N ADDREC,FC,FHFNC,FHFNCN,FHIEN,FHERR,FHLST,FHMSG,FHPGM,FHREC,FLAG,FLDCNT,FLDNUM,FLDVAL
N LC,LPSRT,LPEND,NEWNV,NVN,NVNL,OLDNV,RL,RL1,RL2,RL3,RL4,RL5,RLP,RTN,TAG,UDREC,X,X0,X1,X2,Y
S FHMSG(1)="Nutrition and Food Service patch FH*5.5*26"
S FHMSG(2)="Updating the FOOD NUTRIENTS file (#112) to USDA Standard Release 23"
S FHMSG(3)=""
S FHMSG(4)="Back up of file #112 to ^XTMP starting"
S FHMSG(1,"F")="#",(FHMSG(2,"F"),FHMSG(3,"F"))="!",FHMSG(4,"F")="!!?5"
D EN^DDIOL(.FHMSG) H 2 K FHMSG
;Backup of file #112 to ^XTMP starts here.
D NOW^%DTC ;Getting the system's current date/time
;Creating the Extended temporary globals, setting life span to 180 days after run date
S ^XTMP("FHNU23",0)=$$FMADD^XLFDT($P(%,"."),180)_U_$P(%,".")_U_"File #112 backup, Update to USDA Standard Release 23, FH*5.5*26"
S ^XTMP("FHAR23",0)=$$FMADD^XLFDT($P(%,"."),180)_U_$P(%,".")_U_"Records added by update to USDA Standard Release 23, FH*5.5*26"
S ^XTMP("FHUD23",0)=$$FMADD^XLFDT($P(%,"."),180)_U_$P(%,".")_U_"Records updated by update to USDA Standard Release 23, FH*5.5*26"
S (^XTMP("FHAR23",1),^XTMP("FHUD23",1))=0
K %
M ^XTMP("FHNU23",112)=^FHNU ;file #112 is backed up.
D EN^DDIOL("Back up of file #112 to ^XTMP is complete","","!?5") H 2
;The updating of file #112 starts here.
D EN^DDIOL("Update of file #112 is running.","","!?5") H 2
D EN^DDIOL(" ","","!")
;Processing the FHNDB* routines
S LC=0,X0="000",(X1,X2)=""
F X1=1:1:255 D
. S RTN="FHNDB"_$E(X0,1,$L(X0)-$L(X1))_X1
. D EN^DDIOL(".","","?1"),INC
. I LC>80 D EN^DDIOL("","","!") S LC=1
. ;Processing the current FHNDB routine
. F TAG=1:1:30 D
. . ;Pullinig the embedded data from the current FHNDB routine
. . S RL0=TAG_U_RTN,RL0=$P($T(@RL0),";",3)
. . I RL0="" Q
. . S RL1=TAG_"+1"_U_RTN,RL1=$P($T(@RL1),";",3)
. . S RL2=TAG_"+2"_U_RTN,RL2=$P($T(@RL2),";",3)
. . S RL3=TAG_"+3"_U_RTN,RL3=$P($T(@RL3),";",3)
. . S RL4=TAG_"+4"_U_RTN,RL4=$P($T(@RL4),";",3)
. . ;Setting the work variables
. . S FHFNC=$P(RL0,U,2)
. . S FHFNCN=$P(RL0,U)
. . S (ADDREC,FHIEN,UDREC)=0
. . ;Finding the matching Food Nutrient in file #112
. . K FHERR,FHFDA,FHMSG,FHREC,X
. . S FHIEN=$O(^FHNU("C",FHFNC,FHIEN))
. . I FHIEN="" D
. . . S FHIEN="+1,",FLAG="",X=4,ADDREC=1
. . . S ^XTMP("FHAR23",1)=^XTMP("FHAR23",1)+1
. . . S ^XTMP("FHAR23",2,FHFNC)=FHFNCN_U_RTN_U_TAG
. . E D
. . . S FHIEN=FHIEN_",",FLAG="R",X=5,ADDREC=0
. . . D GETS^DIQ(112,FHIEN,"*","I","FHREC","FHERR")
. . I ADDREC D ZERONODE
. . S RL=RL1,NVNL=$P($T(1),";",3),LPSRT=1,LPEND=20,FLDCNT=10 D WORKNODE
. . S RL=RL2,NVNL=$P($T(2),";",3),LPSRT=1,LPEND=18,FLDCNT=30 D WORKNODE
. . S RL=RL3,NVNL=$P($T(3),";",3),LPSRT=1,LPEND=18,FLDCNT=50 D WORKNODE
. . S RL=RL4,NVNL=$P($T(4),";",3),LPSRT=1,LPEND=10,FLDCNT=70 D WORKNODE
. . I ADDREC D
. . . S FLDNUM=98,FLDVAL="USDA Std. Reference, Release 23" D BLDFDA
. . . D UPDATE^DIE("","FHFDA","","FHERR")
. . I UDREC D
. . . D FILE^DIE("","FHFDA","FHERR")
. . . S ^XTMP("FHUD23",1)=^XTMP("FHUD23",1)+1
. . . S ^XTMP("FHUD23",2,FHFNC)=FHREC(112,FHIEN,.01,"I")
D EN^DDIOL("Update of file #112 is complete.","","!?5")
D RPTUPDT
D RPTADD
Q
ZERONODE ;If adding a record create zero node FDA nodes
S RL=RL0,NVNL=$P($T(0),";",3),LPSRT=1,LPEND=7
F RLP=LPSRT:1:LPEND D
. I $P(RL,U,RLP)="" Q
. S FLDNUM=$P($P(NVNL,U,RLP),"|",2)
. S FLDVAL=$P(RL,U,RLP)
. D BLDFDA
Q
WORKNODE ;Process the data nodes for the current nutrient
F RLP=LPSRT:1:LPEND D
. I $P(RL,U,RLP)="" Q ;If no data in the current field, quit to next field
. S FLDNUM=FLDCNT+RLP ;Compute field number
. S FLDVAL=$P(RL,U,RLP) ;Pull field data value
. ;If adding a new record add the field data value to FDA array and quit to next field
. I ADDREC D BLDFDA Q
. ;If no old value, quit to next field.
. ;This is to filter out nutrients that maybe in the release but not used in file #112
. I '$D(FHREC(112,FHIEN,FLDNUM,"I")) Q
. ;If old value and new values match, quit to next field
. I FHREC(112,FHIEN,FLDNUM,"I")=FLDVAL Q
. D BLDFDA ;Add new field data value to FDA array
. ;Update temporary global to report the update
. S UDREC=1
. S ^XTMP("FHUD23",2,FHFNC,FLDNUM)=$P(NVNL,U,RLP)_U_FHREC(112,FHIEN,FLDNUM,"I")_U_FLDVAL
Q
BLDFDA ;Building the FDA arrary
D FDA^DILF(112,FHIEN,FLDNUM,FLAG,FLDVAL,"FHFDA","FHERR")
Q
RPTADD ;Report the added records
N DIFROM,FHMSG,LC,LPEND,NVNL,RL0,RL1,RL2,RL3,RL4,RLP,RTN,TAG,X,X0,XMDUZ,XMSUB,XMY
D EN^DDIOL(^XTMP("FHAR23",1)_" records were added to file #112 by patch FH*5.5*26","","!?5")
D EN^DDIOL("Creating report of added records.","","!?5")
S (X,X0)=""
K ^TMP($J,"FHMSG")
S ^TMP($J,"FHMSG",1,0)="Update of FOOD NUTRIENTS file (#112) to USDA Standard Release 23."
S ^TMP($J,"FHMSG",2,0)="Records added by patch FH*5.5*26"
S ^TMP($J,"FHMSG",3,0)=$$REPEAT^XLFSTR("-",79)
S LC=4
F S X0=$O(^XTMP("FHAR23",2,X0)) Q:X0="" D
. K FHMSG
. S (RL0,RL1,RL2,RL3,RL4)=""
. S RTN=$P(^XTMP("FHAR23",2,X0),U,2)
. S TAG=$P(^XTMP("FHAR23",2,X0),U,3)
. S RL0=TAG_U_RTN,RL0=$P($T(@RL0),";",3)
. I RL0="" Q
. S RL1=TAG_"+1"_U_RTN,RL1=$P($T(@RL1),";",3)
. S RL2=TAG_"+2"_U_RTN,RL2=$P($T(@RL2),";",3)
. S RL3=TAG_"+3"_U_RTN,RL3=$P($T(@RL3),";",3)
. S RL4=TAG_"+4"_U_RTN,RL4=$P($T(@RL4),";",3)
. S NVNL=$P($T(0),";",3)
. D INC
. S ^TMP($J,"FHMSG",LC,0)=$P($P(NVNL,U),"|")_": "_$P(RL0,U)
. F RLP=3:2:7 D
. . S FHMSG=$P($P(NVNL,U,RLP-1),"|")_": "_$P(RL0,U,RLP-1)
. . S X=$$REPEAT^XLFSTR(" ",40-$L(FHMSG))
. . S FHMSG=FHMSG_X_$P($P(NVNL,U,RLP),"|")_": "_$P(RL0,U,RLP)
. . D INC
. . S ^TMP($J,"FHMSG",LC,0)=FHMSG,(FHMSG,X)=""
. S NVNL=$P($T(1),";",3),RL=RL1,LPEND=20 D RPTADD0
. S NVNL=$P($T(2),";",3),RL=RL2,LPEND=18 D RPTADD0
. S NVNL=$P($T(3),";",3),RL=RL3,LPEND=18 D RPTADD0
. S NVNL=$P($T(4),";",3),RL=RL4,LPEND=10 D RPTADD0
. D INC
. S ^TMP($J,"FHMSG",LC,0)=""
D EN^DDIOL("Sending report by MailMan.","","!?5")
S XMDUZ=.5
S XMSUB="RECORDS ADDED BY PATCH FH*5.5*26"
S XMY(DUZ)=""
S XMTEXT="^TMP($J,""FHMSG"","
D ^XMD
I '$D(XXMG) D EN^DDIOL("Report successfully sent.","","!?5")
K ^TMP($J,"FHMSG")
Q
RPTADD0 ;Print the nutrients of the added record
F RLP=2:2:LPEND D
. S FHMSG=$P(NVNL,U,RLP-1)_": "_$P(RL1,U,RLP-1)
. S X=$$REPEAT^XLFSTR(" ",40-$L(FHMSG))
. S FHMSG=FHMSG_X_$P(NVNL,U,RLP)_": "_$P(RL1,U,RLP)
. D INC
. S ^TMP($J,"FHMSG",LC,0)=FHMSG,(FHMSG,X)=""
Q
RPTUPDT ;Report the updated records
N DIFROM,FHMSG,LC,X,X0,X1,XMDUZ,XMSUB,XMTEXT,XMY
D EN^DDIOL(^XTMP("FHUD23",1)_" records in file #112 were updated by patch FH*5.5*26.","","!?5")
D EN^DDIOL("Creating report of updated records.","","!?5")
K ^TMP($J,"FHMSG")
S ^TMP($J,"FHMSG",1,0)="Update of FOOD NUTRIENTS file (#112) to USDA Standard Release 23"
S ^TMP($J,"FHMSG",2,0)="Records updated by patch FH*5.5*26"
S ^TMP($J,"FHMSG",3,0)=$$REPEAT^XLFSTR("-",79)
S LC=4,(X0,X1)=""
F S X0=$O(^XTMP("FHUD23",2,X0)) Q:X0="" D
. K FHMSG
. D INC
. S ^TMP($J,"FHMSG",LC,0)="FOOD: "_X0_" - "_^XTMP("FHUD23",2,X0)
. S FHMSG="Nutrient"
. S X=$$REPEAT^XLFSTR(" ",40-$L(FHMSG)),FHMSG=FHMSG_X_"Old value",X=""
. S X=$$REPEAT^XLFSTR(" ",60-$L(FHMSG)),FHMSG=FHMSG_X_"New value",X=""
. D INC S ^TMP($J,"FHMSG",LC,0)=FHMSG,FHMSG=""
. D INC S ^TMP($J,"FHMSG",LC,0)=$$REPEAT^XLFSTR("-",79)
. F S X1=$O(^XTMP("FHUD23",2,X0,X1)) Q:X1="" D
. . S FHMSG=$P(^XTMP("FHUD23",2,X0,X1),U)
. . S X=$$REPEAT^XLFSTR(" ",40-$L(FHMSG))
. . S FHMSG=FHMSG_X_$P(^XTMP("FHUD23",2,X0,X1),U,2)
. . S X=$$REPEAT^XLFSTR(" ",60-$L(FHMSG))
. . S FHMSG=FHMSG_X_$P(^XTMP("FHUD23",2,X0,X1),U,3)
. . D INC S ^TMP($J,"FHMSG",LC,0)=FHMSG,FHMSG=""
. D INC S ^TMP($J,"FHMSG",LC,0)=""
D EN^DDIOL("Sending report by MailMan.","","!?5")
S XMDUZ=.5
S XMSUB="RECORDS UPDATED BY PATCH FH*5.5*26"
S XMY(DUZ)=""
S XMTEXT="^TMP($J,""FHMSG"","
D ^XMD
I '$D(XMMG) D EN^DDIOL("Report successfully sent.","","!?5")
K ^TMP($J,"FHMSG")
Q
INC ;Increment line counter variable LC
S LC=LC+1 Q
;Field names for the user message display
0 ;;NAME|.01^CODE|1^COMMON UNITS|2^GRAMS/COMMON UNIT|3^% AS PURCHASED|5^EDITABLE?|6^TYPE|7
1 ;;PROTEIN^LIPIDS^CARBOHYDRATE^FOOD ENERGY^WATER^^^CALCIUM^IRON^MAGNESIUM^PHOSPHORUS^POTASSIUM^SODIUM^ZINC^COPPER^MANGANESE^ALPHA TOCOPHEROL^VITAMIN A^ASCORBIC ACID^THIAMIN
2 ;;RIBOFLAVIN^NIACIN^PANTOTHENIC ACID^VITAMIN B6^FOLATE^VITAMIN B12^LINOLEIC ACID^LINOLENIC ACID^CHOLESTEROL^SATURATED FAT^MONOUNSATURATED FAT^POLYUNSATURATED FAT^VITAMIN A^ASH^ALCOHOL^CAFFEINE^TOTAL DIETARY FIBER^TOTAL TOCOPHEROL
3 ;;TRYPTOPHAN^THREONINE^ISOLEUCINE^LEUCINE^LYSINE^METHIONINE^CYSTINE^PHENYLALANINE^TYROSINE^VALINE^ARGININE^HISTIDINE^ALANINE^ASPARTIC ACID^GLUTAMIC ACID^GLYCINE^PROLINE^SERINE^
4 ;;CAPRIC ACID^LAURIC ACID^MYRISTIC ACID^PALMITIC ACID^PALMITOLEIC ACID^STEARIC ACID^OLEIC ACID^ARACHIDONIC ACID^VITAMIN K^SELENIUM
5 ;;SOURCE OF DATA
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFHUD112 9262 printed Nov 22, 2024@17:05:23 Page 2
FHUD112 ;SLC/GDU - UPDATE FILE #112 TO CURRENT USDA NUTRITIONAL DATABASE
+1 ;;5.5;DIETETICS;**26**;Jan 28, 2005;Build 17
+2 ;
+3 ;USDA National Nutrient Database for Standard Reference, Release 23
+4 ;Data to update the FOOD NUTRIENTS FILE, #112
+5 ;Routine is not intended to be called by name alone.
+6 QUIT
EN ;Entry point of this routine
+1 NEW ADDREC,FC,FHFNC,FHFNCN,FHIEN,FHERR,FHLST,FHMSG,FHPGM,FHREC,FLAG,FLDCNT,FLDNUM,FLDVAL
+2 NEW LC,LPSRT,LPEND,NEWNV,NVN,NVNL,OLDNV,RL,RL1,RL2,RL3,RL4,RL5,RLP,RTN,TAG,UDREC,X,X0,X1,X2,Y
+3 SET FHMSG(1)="Nutrition and Food Service patch FH*5.5*26"
+4 SET FHMSG(2)="Updating the FOOD NUTRIENTS file (#112) to USDA Standard Release 23"
+5 SET FHMSG(3)=""
+6 SET FHMSG(4)="Back up of file #112 to ^XTMP starting"
+7 SET FHMSG(1,"F")="#"
SET (FHMSG(2,"F"),FHMSG(3,"F"))="!"
SET FHMSG(4,"F")="!!?5"
+8 DO EN^DDIOL(.FHMSG)
HANG 2
KILL FHMSG
+9 ;Backup of file #112 to ^XTMP starts here.
+10 ;Getting the system's current date/time
DO NOW^%DTC
+11 ;Creating the Extended temporary globals, setting life span to 180 days after run date
+12 SET ^XTMP("FHNU23",0)=$$FMADD^XLFDT($PIECE(%,"."),180)_U_$PIECE(%,".")_U_"File #112 backup, Update to USDA Standard Release 23, FH*5.5*26"
+13 SET ^XTMP("FHAR23",0)=$$FMADD^XLFDT($PIECE(%,"."),180)_U_$PIECE(%,".")_U_"Records added by update to USDA Standard Release 23, FH*5.5*26"
+14 SET ^XTMP("FHUD23",0)=$$FMADD^XLFDT($PIECE(%,"."),180)_U_$PIECE(%,".")_U_"Records updated by update to USDA Standard Release 23, FH*5.5*26"
+15 SET (^XTMP("FHAR23",1),^XTMP("FHUD23",1))=0
+16 KILL %
+17 ;file #112 is backed up.
MERGE ^XTMP("FHNU23",112)=^FHNU
+18 DO EN^DDIOL("Back up of file #112 to ^XTMP is complete","","!?5")
HANG 2
+19 ;The updating of file #112 starts here.
+20 DO EN^DDIOL("Update of file #112 is running.","","!?5")
HANG 2
+21 DO EN^DDIOL(" ","","!")
+22 ;Processing the FHNDB* routines
+23 SET LC=0
SET X0="000"
SET (X1,X2)=""
+24 FOR X1=1:1:255
Begin DoDot:1
+25 SET RTN="FHNDB"_$EXTRACT(X0,1,$LENGTH(X0)-$LENGTH(X1))_X1
+26 DO EN^DDIOL(".","","?1")
DO INC
+27 IF LC>80
DO EN^DDIOL("","","!")
SET LC=1
+28 ;Processing the current FHNDB routine
+29 FOR TAG=1:1:30
Begin DoDot:2
+30 ;Pullinig the embedded data from the current FHNDB routine
+31 SET RL0=TAG_U_RTN
SET RL0=$PIECE($TEXT(@RL0),";",3)
+32 IF RL0=""
QUIT
+33 SET RL1=TAG_"+1"_U_RTN
SET RL1=$PIECE($TEXT(@RL1),";",3)
+34 SET RL2=TAG_"+2"_U_RTN
SET RL2=$PIECE($TEXT(@RL2),";",3)
+35 SET RL3=TAG_"+3"_U_RTN
SET RL3=$PIECE($TEXT(@RL3),";",3)
+36 SET RL4=TAG_"+4"_U_RTN
SET RL4=$PIECE($TEXT(@RL4),";",3)
+37 ;Setting the work variables
+38 SET FHFNC=$PIECE(RL0,U,2)
+39 SET FHFNCN=$PIECE(RL0,U)
+40 SET (ADDREC,FHIEN,UDREC)=0
+41 ;Finding the matching Food Nutrient in file #112
+42 KILL FHERR,FHFDA,FHMSG,FHREC,X
+43 SET FHIEN=$ORDER(^FHNU("C",FHFNC,FHIEN))
+44 IF FHIEN=""
Begin DoDot:3
+45 SET FHIEN="+1,"
SET FLAG=""
SET X=4
SET ADDREC=1
+46 SET ^XTMP("FHAR23",1)=^XTMP("FHAR23",1)+1
+47 SET ^XTMP("FHAR23",2,FHFNC)=FHFNCN_U_RTN_U_TAG
End DoDot:3
+48 IF '$TEST
Begin DoDot:3
+49 SET FHIEN=FHIEN_","
SET FLAG="R"
SET X=5
SET ADDREC=0
+50 DO GETS^DIQ(112,FHIEN,"*","I","FHREC","FHERR")
End DoDot:3
+51 IF ADDREC
DO ZERONODE
+52 SET RL=RL1
SET NVNL=$PIECE($TEXT(1),";",3)
SET LPSRT=1
SET LPEND=20
SET FLDCNT=10
DO WORKNODE
+53 SET RL=RL2
SET NVNL=$PIECE($TEXT(2),";",3)
SET LPSRT=1
SET LPEND=18
SET FLDCNT=30
DO WORKNODE
+54 SET RL=RL3
SET NVNL=$PIECE($TEXT(3),";",3)
SET LPSRT=1
SET LPEND=18
SET FLDCNT=50
DO WORKNODE
+55 SET RL=RL4
SET NVNL=$PIECE($TEXT(4),";",3)
SET LPSRT=1
SET LPEND=10
SET FLDCNT=70
DO WORKNODE
+56 IF ADDREC
Begin DoDot:3
+57 SET FLDNUM=98
SET FLDVAL="USDA Std. Reference, Release 23"
DO BLDFDA
+58 DO UPDATE^DIE("","FHFDA","","FHERR")
End DoDot:3
+59 IF UDREC
Begin DoDot:3
+60 DO FILE^DIE("","FHFDA","FHERR")
+61 SET ^XTMP("FHUD23",1)=^XTMP("FHUD23",1)+1
+62 SET ^XTMP("FHUD23",2,FHFNC)=FHREC(112,FHIEN,.01,"I")
End DoDot:3
End DoDot:2
End DoDot:1
+63 DO EN^DDIOL("Update of file #112 is complete.","","!?5")
+64 DO RPTUPDT
+65 DO RPTADD
+66 QUIT
ZERONODE ;If adding a record create zero node FDA nodes
+1 SET RL=RL0
SET NVNL=$PIECE($TEXT(0),";",3)
SET LPSRT=1
SET LPEND=7
+2 FOR RLP=LPSRT:1:LPEND
Begin DoDot:1
+3 IF $PIECE(RL,U,RLP)=""
QUIT
+4 SET FLDNUM=$PIECE($PIECE(NVNL,U,RLP),"|",2)
+5 SET FLDVAL=$PIECE(RL,U,RLP)
+6 DO BLDFDA
End DoDot:1
+7 QUIT
WORKNODE ;Process the data nodes for the current nutrient
+1 FOR RLP=LPSRT:1:LPEND
Begin DoDot:1
+2 ;If no data in the current field, quit to next field
IF $PIECE(RL,U,RLP)=""
QUIT
+3 ;Compute field number
SET FLDNUM=FLDCNT+RLP
+4 ;Pull field data value
SET FLDVAL=$PIECE(RL,U,RLP)
+5 ;If adding a new record add the field data value to FDA array and quit to next field
+6 IF ADDREC
DO BLDFDA
QUIT
+7 ;If no old value, quit to next field.
+8 ;This is to filter out nutrients that maybe in the release but not used in file #112
+9 IF '$DATA(FHREC(112,FHIEN,FLDNUM,"I"))
QUIT
+10 ;If old value and new values match, quit to next field
+11 IF FHREC(112,FHIEN,FLDNUM,"I")=FLDVAL
QUIT
+12 ;Add new field data value to FDA array
DO BLDFDA
+13 ;Update temporary global to report the update
+14 SET UDREC=1
+15 SET ^XTMP("FHUD23",2,FHFNC,FLDNUM)=$PIECE(NVNL,U,RLP)_U_FHREC(112,FHIEN,FLDNUM,"I")_U_FLDVAL
End DoDot:1
+16 QUIT
BLDFDA ;Building the FDA arrary
+1 DO FDA^DILF(112,FHIEN,FLDNUM,FLAG,FLDVAL,"FHFDA","FHERR")
+2 QUIT
RPTADD ;Report the added records
+1 NEW DIFROM,FHMSG,LC,LPEND,NVNL,RL0,RL1,RL2,RL3,RL4,RLP,RTN,TAG,X,X0,XMDUZ,XMSUB,XMY
+2 DO EN^DDIOL(^XTMP("FHAR23",1)_" records were added to file #112 by patch FH*5.5*26","","!?5")
+3 DO EN^DDIOL("Creating report of added records.","","!?5")
+4 SET (X,X0)=""
+5 KILL ^TMP($JOB,"FHMSG")
+6 SET ^TMP($JOB,"FHMSG",1,0)="Update of FOOD NUTRIENTS file (#112) to USDA Standard Release 23."
+7 SET ^TMP($JOB,"FHMSG",2,0)="Records added by patch FH*5.5*26"
+8 SET ^TMP($JOB,"FHMSG",3,0)=$$REPEAT^XLFSTR("-",79)
+9 SET LC=4
+10 FOR
SET X0=$ORDER(^XTMP("FHAR23",2,X0))
if X0=""
QUIT
Begin DoDot:1
+11 KILL FHMSG
+12 SET (RL0,RL1,RL2,RL3,RL4)=""
+13 SET RTN=$PIECE(^XTMP("FHAR23",2,X0),U,2)
+14 SET TAG=$PIECE(^XTMP("FHAR23",2,X0),U,3)
+15 SET RL0=TAG_U_RTN
SET RL0=$PIECE($TEXT(@RL0),";",3)
+16 IF RL0=""
QUIT
+17 SET RL1=TAG_"+1"_U_RTN
SET RL1=$PIECE($TEXT(@RL1),";",3)
+18 SET RL2=TAG_"+2"_U_RTN
SET RL2=$PIECE($TEXT(@RL2),";",3)
+19 SET RL3=TAG_"+3"_U_RTN
SET RL3=$PIECE($TEXT(@RL3),";",3)
+20 SET RL4=TAG_"+4"_U_RTN
SET RL4=$PIECE($TEXT(@RL4),";",3)
+21 SET NVNL=$PIECE($TEXT(0),";",3)
+22 DO INC
+23 SET ^TMP($JOB,"FHMSG",LC,0)=$PIECE($PIECE(NVNL,U),"|")_": "_$PIECE(RL0,U)
+24 FOR RLP=3:2:7
Begin DoDot:2
+25 SET FHMSG=$PIECE($PIECE(NVNL,U,RLP-1),"|")_": "_$PIECE(RL0,U,RLP-1)
+26 SET X=$$REPEAT^XLFSTR(" ",40-$LENGTH(FHMSG))
+27 SET FHMSG=FHMSG_X_$PIECE($PIECE(NVNL,U,RLP),"|")_": "_$PIECE(RL0,U,RLP)
+28 DO INC
+29 SET ^TMP($JOB,"FHMSG",LC,0)=FHMSG
SET (FHMSG,X)=""
End DoDot:2
+30 SET NVNL=$PIECE($TEXT(1),";",3)
SET RL=RL1
SET LPEND=20
DO RPTADD0
+31 SET NVNL=$PIECE($TEXT(2),";",3)
SET RL=RL2
SET LPEND=18
DO RPTADD0
+32 SET NVNL=$PIECE($TEXT(3),";",3)
SET RL=RL3
SET LPEND=18
DO RPTADD0
+33 SET NVNL=$PIECE($TEXT(4),";",3)
SET RL=RL4
SET LPEND=10
DO RPTADD0
+34 DO INC
+35 SET ^TMP($JOB,"FHMSG",LC,0)=""
End DoDot:1
+36 DO EN^DDIOL("Sending report by MailMan.","","!?5")
+37 SET XMDUZ=.5
+38 SET XMSUB="RECORDS ADDED BY PATCH FH*5.5*26"
+39 SET XMY(DUZ)=""
+40 SET XMTEXT="^TMP($J,""FHMSG"","
+41 DO ^XMD
+42 IF '$DATA(XXMG)
DO EN^DDIOL("Report successfully sent.","","!?5")
+43 KILL ^TMP($JOB,"FHMSG")
+44 QUIT
RPTADD0 ;Print the nutrients of the added record
+1 FOR RLP=2:2:LPEND
Begin DoDot:1
+2 SET FHMSG=$PIECE(NVNL,U,RLP-1)_": "_$PIECE(RL1,U,RLP-1)
+3 SET X=$$REPEAT^XLFSTR(" ",40-$LENGTH(FHMSG))
+4 SET FHMSG=FHMSG_X_$PIECE(NVNL,U,RLP)_": "_$PIECE(RL1,U,RLP)
+5 DO INC
+6 SET ^TMP($JOB,"FHMSG",LC,0)=FHMSG
SET (FHMSG,X)=""
End DoDot:1
+7 QUIT
RPTUPDT ;Report the updated records
+1 NEW DIFROM,FHMSG,LC,X,X0,X1,XMDUZ,XMSUB,XMTEXT,XMY
+2 DO EN^DDIOL(^XTMP("FHUD23",1)_" records in file #112 were updated by patch FH*5.5*26.","","!?5")
+3 DO EN^DDIOL("Creating report of updated records.","","!?5")
+4 KILL ^TMP($JOB,"FHMSG")
+5 SET ^TMP($JOB,"FHMSG",1,0)="Update of FOOD NUTRIENTS file (#112) to USDA Standard Release 23"
+6 SET ^TMP($JOB,"FHMSG",2,0)="Records updated by patch FH*5.5*26"
+7 SET ^TMP($JOB,"FHMSG",3,0)=$$REPEAT^XLFSTR("-",79)
+8 SET LC=4
SET (X0,X1)=""
+9 FOR
SET X0=$ORDER(^XTMP("FHUD23",2,X0))
if X0=""
QUIT
Begin DoDot:1
+10 KILL FHMSG
+11 DO INC
+12 SET ^TMP($JOB,"FHMSG",LC,0)="FOOD: "_X0_" - "_^XTMP("FHUD23",2,X0)
+13 SET FHMSG="Nutrient"
+14 SET X=$$REPEAT^XLFSTR(" ",40-$LENGTH(FHMSG))
SET FHMSG=FHMSG_X_"Old value"
SET X=""
+15 SET X=$$REPEAT^XLFSTR(" ",60-$LENGTH(FHMSG))
SET FHMSG=FHMSG_X_"New value"
SET X=""
+16 DO INC
SET ^TMP($JOB,"FHMSG",LC,0)=FHMSG
SET FHMSG=""
+17 DO INC
SET ^TMP($JOB,"FHMSG",LC,0)=$$REPEAT^XLFSTR("-",79)
+18 FOR
SET X1=$ORDER(^XTMP("FHUD23",2,X0,X1))
if X1=""
QUIT
Begin DoDot:2
+19 SET FHMSG=$PIECE(^XTMP("FHUD23",2,X0,X1),U)
+20 SET X=$$REPEAT^XLFSTR(" ",40-$LENGTH(FHMSG))
+21 SET FHMSG=FHMSG_X_$PIECE(^XTMP("FHUD23",2,X0,X1),U,2)
+22 SET X=$$REPEAT^XLFSTR(" ",60-$LENGTH(FHMSG))
+23 SET FHMSG=FHMSG_X_$PIECE(^XTMP("FHUD23",2,X0,X1),U,3)
+24 DO INC
SET ^TMP($JOB,"FHMSG",LC,0)=FHMSG
SET FHMSG=""
End DoDot:2
+25 DO INC
SET ^TMP($JOB,"FHMSG",LC,0)=""
End DoDot:1
+26 DO EN^DDIOL("Sending report by MailMan.","","!?5")
+27 SET XMDUZ=.5
+28 SET XMSUB="RECORDS UPDATED BY PATCH FH*5.5*26"
+29 SET XMY(DUZ)=""
+30 SET XMTEXT="^TMP($J,""FHMSG"","
+31 DO ^XMD
+32 IF '$DATA(XMMG)
DO EN^DDIOL("Report successfully sent.","","!?5")
+33 KILL ^TMP($JOB,"FHMSG")
+34 QUIT
INC ;Increment line counter variable LC
+1 SET LC=LC+1
QUIT
+2 ;Field names for the user message display
0 ;;NAME|.01^CODE|1^COMMON UNITS|2^GRAMS/COMMON UNIT|3^% AS PURCHASED|5^EDITABLE?|6^TYPE|7
1 ;;PROTEIN^LIPIDS^CARBOHYDRATE^FOOD ENERGY^WATER^^^CALCIUM^IRON^MAGNESIUM^PHOSPHORUS^POTASSIUM^SODIUM^ZINC^COPPER^MANGANESE^ALPHA TOCOPHEROL^VITAMIN A^ASCORBIC ACID^THIAMIN
2 ;;RIBOFLAVIN^NIACIN^PANTOTHENIC ACID^VITAMIN B6^FOLATE^VITAMIN B12^LINOLEIC ACID^LINOLENIC ACID^CHOLESTEROL^SATURATED FAT^MONOUNSATURATED FAT^POLYUNSATURATED FAT^VITAMIN A^ASH^ALCOHOL^CAFFEINE^TOTAL DIETARY FIBER^TOTAL TOCOPHEROL
3 ;;TRYPTOPHAN^THREONINE^ISOLEUCINE^LEUCINE^LYSINE^METHIONINE^CYSTINE^PHENYLALANINE^TYROSINE^VALINE^ARGININE^HISTIDINE^ALANINE^ASPARTIC ACID^GLUTAMIC ACID^GLYCINE^PROLINE^SERINE^
4 ;;CAPRIC ACID^LAURIC ACID^MYRISTIC ACID^PALMITIC ACID^PALMITOLEIC ACID^STEARIC ACID^OLEIC ACID^ARACHIDONIC ACID^VITAMIN K^SELENIUM
5 ;;SOURCE OF DATA