This is my code:
{if OBSNOW("WEIGHT (KG)") > "0" then OBSNOW("EPINEPH DOSE")=(OBSNOW("WEIGHT (KG)")*.01)
if OBSNOW("EPINEPH DOSE") > "0.5" then OBSNOW("EPINEPH DOSE")="0.5" else OBSNOW("EPINEPH DOSE") endif else "" endif}
It works great as a data display however I want EPINEPH DOSE to translate to the text portion of the note but the value isn't being written to that obs term. What am I doing wrong? I know I can probably make this all work with a button but I'd rather have it just do it automatically. Possible?
To assign values to OBS, you cannot use =
Do this
.
OBSNOW(“EPINEPH DOSE”, ( OBSNOW(“WEIGHT (KG)”)*.01) )
Doesn't work.
"Error: 32783 Invalid operation or bad symbol types: obsnow"
The problem is probably with the calculation...try this...
local thisdose=""
if val(OBSNOW("WEIGHT (KG)"))>0 then
thisdose = str(val(OBSNOW("WEIGHT (KG)")) * 0.01)
OBSNOW(“EPINEPH DOSE”, thisdose )
else
""
endif
Now it says invalid symbol of VAL. I have the box set as a data display with a MEL expression. I'm assuming what you posted should be in the whiteboard?
Maybe the Data display is trying to run the calculation before OBSNOW("...") has been set to a value. ...try this...
if OK(OBSNOW("WEIGHT (KG)"))
and OBSNOW("WEIGHT (KG)")<>"" then
if val(OBSNOW("WEIGHT (KG)"))>0 then
local thisdose = str(val(OBSNOW("WEIGHT (KG)")) * 0.01)
OBSNOW(“EPINEPH DOSE”, thisdose )
else
""
endif
endif