I need help with a calculation in VFE. I'm looking for instructions on a simple calculation for the following scenerio - observaction terms in parenthases below:
(AB INDEX L#1) divided by (LTBRACHBPDIA) equals (ABI L RESTNG)
a / b = x
I'd prefer that the result (x) automatically populates IF a and b are entered during this encounter (OBNOW).
Thanks, Sharon
All obs terms are stored as strings. Must convert string to value for computation and value results to strings to store in obs terms, e.g.
obsnow("X",ABI_Calc(obsnow("A"),obsnow("B"))
.
.
.
{fn ABI_Calc(strA,strB)
{
local strResult=""
strResult=str(val(strA)/val(strB)
}
}
Sharon,
Dr. Fitzgerald is correct. You must convert the string values to numeric before you can perform the calculation. If you are wanting the calculation to update each time you enter a value for the OBS terms AB INDEX L#1 and LTBRACHBPDIA; you might want to include a watcher expression in the function view that calls the calculation function as follows:
//Update calculation when numerator and denominator OBS terms get updated
{
!if ((OBSNOW("AB INDEX L#1") <> UNDEFINED) and (OBSNOW("LTBRACHBPDIA") <> UNDEFINED)) then
//Execute function to update ABI calculation
ABI_Calc(OBSNOW("AB INDEX L#1"),OBSNOW("LTBRACHBPDIA"))
else
//Do nothing
endif
}
//Function definition (include in function view)
{fn ABI_Calc(strA,strB)
{
local strResult=""
strResult=str(val(strA)/val(strB))
//update calculation OBS term
OBSNOW("ABI L RESTNG",strResult)
}
}