Okay, maybe somebody can see what I am missing. I have a form that has a doc variable with 5 choices. I am trying to get them to default based of the patients BMI. I can make it work on the first 2 choices based of bmi, but not any of the others.
Here is the function I am using:
{!IF OBSNOW("BMI") == "" THEN ""
ELSE IF OBSNOW("BMI")<= "15"
THEN DOCUMENT.SPINE_WEIGHT = "cachectic"
ELSE IF (OBSNOW("BMI") >= "15.1" OR OBSNOW("BMI")<= "18.5")
THEN DOCUMENT.SPINE_WEIGHT = "slim"
ELSE IF (OBSNOW("BMI") >= "18.6" OR OBSNOW("BMI")<= "25")
THEN DOCUMENT.SPINE_WEIGHT = " average weight"
ELSE IF (OBSNOW("BMI") >= "25.1" OR OBSNOW("BMI")<= "30")
THEN DOCUMENT.SPINE_WEIGHT = "overweight"
ELSE IF OBSNOW("BMI") >= "30.1"
THEN DOCUMENT.SPINE_WEIGHT = "obese"
ELSE ""
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF}
Once I figure out how to attach items, i will attach the dlg file of the form.
Here is the file
Ernie
You might try 'and' instead of 'or'.
Doh that was it. I knew it was something I was over looking.
Thanks
Ernie,
As an alternative, either of these snippets should accomplish the same thing and might be a little easier to maintain if you're making changes to the code later.
{!IF OBSNOW("BMI") == "" THEN ""
ELSE IF OBSNOW("BMI")<= "15"
THEN DOCUMENT.SPINE_WEIGHT = "cachectic"
ELSE IF OBSNOW("BMI")<= "18.5"
THEN DOCUMENT.SPINE_WEIGHT = "slim"
ELSE IF OBSNOW("BMI")<= "25"
THEN DOCUMENT.SPINE_WEIGHT = " average weight"
ELSE OBSNOW("BMI")<= "30"
THEN DOCUMENT.SPINE_WEIGHT = "overweight"
ELSE IF OBSNOW("BMI") >= "30.1"
THEN DOCUMENT.SPINE_WEIGHT = "obese"
ELSE ""
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF}
Or,
{!COND
CASE OBSNOW("BMI")<= "15"
DOCUMENT.SPINE_WEIGHT = "cachectic"
CASE OBSNOW("BMI")<= "18.5"
DOCUMENT.SPINE_WEIGHT = "slim"
CASE OBSNOW("BMI")<= "25"
DOCUMENT.SPINE_WEIGHT = " average weight"
CASE OBSNOW("BMI")<= "30"
DOCUMENT.SPINE_WEIGHT = "overweight"
CASE OBSNOW("BMI") >= "30.1"
DOCUMENT.SPINE_WEIGHT = "obese"
ELSE ""
ENDCOND}