VistA-WorldVistAEHR/r/GEN_MED_REC_VITALS-GMRV/GMRVBMI.m

32 lines
1.8 KiB
Mathematica

GMRVBMI ;HIRMFO/YH-EXTRACT HEIGHT TO CALCULATE BMI FOR WEIGHT; 3/24/97
;;4.0;Vitals/Measurements;**1**;Apr 25, 1997
HT ;OBTAIN THE LATEST HEIGHT FOR THE CURRENT WEIGHT
K GHEIGHT S GI=$O(^GMRD(120.51,"B","HEIGHT",0)) Q:GI'>0
S GH=0 F S GH=$O(^GMR(120.5,"AA",DFN,GI,GH)) Q:GH'>0 S GH(1)=0 F S GH(1)=$O(^GMR(120.5,"AA",DFN,GI,GH,GH(1))) Q:GH(1)'>0 I $D(^GMR(120.5,GH(1),0)),'$D(^GMR(120.5,GH(1),2)),$P(^GMR(120.5,GH(1),0),"^",8)'="" D
. I $P(^GMR(120.5,GH(1),0),"^",8)>0 S GHEIGHT($P(^(0),"^"))=$P(^(0),"^",8)
Q
CALBMI(GBMI) ;OBTAIN HEIGHT TO CALCULATE BMI
N GDATE,GMRVHT S GMRVHT="" D HT I '$D(GHEIGHT) K GHEIGHT,GI,GH Q
;HEIGHT AND WEIGHT WERE OBTAINED AT THE SAME TIME
I $D(GHEIGHT(GBMI(1))) D K GHEIGHT,GH,GI Q
. S GBMI(2)=GBMI(2)/2.2,GMRVHT=+GHEIGHT(GBMI(1))*2.54/100
. I +GMRVHT'>0 S GBMI=$J(0,0,0) Q
. S GBMI=$J(GBMI(2)/(GMRVHT*GMRVHT),0,0) S GBMI=GBMI_$S(GBMI>27:"*",1:"")
;EXTRACT THE HEIGHT TAKEN BEFORE THE WEIGHT WAS TAKEN
S GDATE=9999999-GBMI(1),GDATE(1)=0 F S GDATE=$O(^GMR(120.5,"AA",DFN,GI,GDATE)) Q:GDATE'>0!(GDATE(1)>0) D
. S G=$O(^GMR(120.5,"AA",DFN,GI,GDATE,0)) Q:G'>0 I $P($G(^GMR(120.5,G,0)),"^",8)'>0 Q
. S GDATE(1)=GDATE
;EXTRACT THE HEIGHT TAKEN AFTER THE WEIGHT WAS TAKEN
I GDATE(1)>0,$D(GHEIGHT(9999999-GDATE(1))) D K GHEIGHT,GH,GI Q
. S GDATE(1)=9999999-GDATE(1),GMRVHT=+GHEIGHT(GDATE(1))
. S GBMI(2)=GBMI(2)/2.2,GMRVHT=GMRVHT*2.54/100
. I +GMRVHT'>0 S GBMI=$J(0,0,0) Q
. S GBMI=$J(GBMI(2)/(GMRVHT*GMRVHT),0,0),GBMI=GBMI_$S(GBMI>27:"*",1:"")
S GDATE=GBMI(1),GDATE(1)=0 F S GDATE=$O(GHEIGHT(GDATE)) Q:GDATE'>0!(GDATE(1)>0) S GDATE(1)=GDATE
I GDATE(1)>0 D K GHEIGHT,GH,GI,G Q
. S GMRVHT=+GHEIGHT(GDATE(1))
. S GBMI(2)=GBMI(2)/2.2,GMRVHT=GMRVHT*2.54/100
. I +GMRVHT'>0 S GBMI=$J(0,0,0) Q
. S GBMI=$J(GBMI(2)/(GMRVHT*GMRVHT),0,0),GBMI=GBMI_$S(GBMI>27:"*",1:"")
K GHEIGHT,GI,GH,G Q