In my new spirometry form, this calculation works but is putting a decimal point in the result. Does anyone know how I can take the decimal out of the result?
For instance 3.12/2.86 should be 109, not 1.09
//Calculate %Pred
{
!if ((OBSNOW("FVC") <> UNDEFINED) and (OBSNOW("FVC PREDICT") <> UNDEFINED)) then
PRED_Calc(OBSNOW("FVC"),OBSNOW("FVC PREDICT"))
else
//Do nothing
endif
}
//Function definition (include in function view)
{fn PRED_Calc(strA,strB)
{
local strResult=""
strResult=str(val(strB)/val(strA))
//update calculation OBS term
OBSNOW("FVC % EXPECT",strResult)
}
}
Stacey LaGrange
Mid Coast – Parkview Health Services
Phone (207) 373-2121
[email protected]
This may be over simplifying what you are asking for, but does it make sense to simply multiply the strResult by 100? That would move the decimal two places over.
MEL function: round(value, point), where value is the number to round, point is the number of places after the decimal point,
I think you are right, I had just found this idea in an old MEL power point I have and was giving it a try. It seems to work if I multiple strB by 100 first, then I could combine this with round or truncate if I have to, thank you!
I have this working to the point this displays 109.00 now but no matter how I try to truncate this it won't work. I know I can't truncate a string and tried different ways but no luck. Any ideas?
//Calculate %Pred
{
!if ((OBSNOW("FVC") <> UNDEFINED) and (OBSNOW("FVC PREDICT") <> UNDEFINED)) then
PRED_Calc(OBSNOW("FVC"),OBSNOW("FVC PREDICT"))
else
//Do nothing
endif
}
//Function definition (include in function view)
{fn PRED_Calc(strA,strB)
{
local strResult=""
local strFormat=""
strResult=str(val(strB)/val(strA))
strFormat = str(val(strResult) * 100)
OBSNOW("FVC % EXPECT",strFormat)
}
}
I finally figured this out so all set.
//Calculate %Pred
{
!if ((OBSNOW("FVC") <> UNDEFINED) and (OBSNOW("FVC PREDICT") <> UNDEFINED)) then
PRED_Calc(OBSNOW("FVC"),OBSNOW("FVC PREDICT"))
else
//Do nothing
endif
}
//Function definition (include in function view)
{fn PRED_Calc(strA,strB)
{
local strResult=""
local strFormat=""
local numDec=""
local strDec=""
strResult=str(val(strB)/val(strA))
strFormat = str(val(strResult) * 100)
numDec = val(strFormat)
strDec = str(truncate(numDec,0))
OBSNOW("FVC % EXPECT",strDec)
}
}