We have two forms in one template that contain weight and height and have it setup to calculate BMI. Sometimes the BMI will completely disappear from the chart note, then later reappear... could it a problem with the code in both forms? BMI field only appears in one of the forms.
Any help would be greatly appreciated.
Thanks,
Misti
Can you post the code that you are using?
This form was created by someone else... I am new to VFE and haven't had much training on MEL. Is there a way to attach the form to this post?
Here is the code.
{ DOCUMENT.BODY_MASS_IN = str(CalcBMIConv(gHEIGHT,gHEIGHTPREV,gWEIGHT))
}
{fn CalcBMIConv(heightnow,heightprev,weightnow) {
local heightval = ""
cond
case heightnow <> ""
heightval = heightnow
case heightprev <> ""
heightval = heightprev
else
heightval = ""
endcond
if weightnow == "" or heightval == "" then
return ""
endif
if heightval == 0 then
return str(0)
endif
return str((weightnow / 2.2) / ((heightval / 39.4)^2))
}}
I use document variables instead of global variables, I have never had a problem, trying using this instead of the first line you posted -
{DOCUMENT.TEMP_veHEIGHTNOW = OBSNOW("Height")}
{DOCUMENT.TEMP_veHEIGHTPREV = OBSPREV("Height")}
{DOCUMENT.TEMP_veWEIGHTNOW = OBSNOW("Weight")}
{DOCUMENT.BODY_MASS_IN = str(CalcBMIConv(DOCUMENT.TEMP_veHEIGHTNOW,DOCUMENT.TEMP_veHEIGHTPREV,DOCUMENT.TEMP_veWEIGHTNOW))}
Thank you! I will try it out.