0

I am working on a CRF with REDCap for a master project however I have run into a problem with some programming.

I'm trying to set up an equation for some intervals, the following example is for body temperature (in Celsius). I am trying to integrate a scoring model into one of my instruments. If the temperature is 36-38.4 it is supposed to give 0 points, if it is between 32-33.9 it will give 2 points etc. My problem is that both a very low number and a very high number gives 4 points and I can't figure out how to program the equation.

This is how REDCap uses conditional logic: if (CONDITION, value if condition is TRUE, value if condition is FALSE).

This is a equation that works for example:

if([cpis_temp] > 35.9,if([cpis_temp] > 38.4,if([cpis_temp] >=39, 2, 1),0),2)

Now I want to make another but with more intervals but I can't get the equation to work, these are the intervals:

 0 if: 36-38.4

 1 if: 34-35.9 or 38.5-38.9

 2 if: 32-33.9

 3 if: 30-31.9 or 39-40.9

 4 if: <=29.9 or >=41

This is what I have managed to formulate so far:

if([cpis_temp]>1,if([cpis_temp]>20,if([cpis_temp]>=30,if([cpis_temp]>=32,if([cpis_temp]>=34,if([cpis_temp]>=36,if([cpis_temp]=>38.5,if([cpis_temp]>=39,if([cpis_temp]>=41,4,0),3),1),0),1),2),3),4),0)

Grateful for some input and help!

wibeasley
  • 5,000
  • 3
  • 34
  • 62

1 Answers1

1

I'd suggest starting at one end of this continuous variable and coding from there:

if([cpis_temp] < 30, 4,
  if([cpis_temp] < 32, 3,
    if([cpis_temp] < 34, 2,
      if([cpis_temp] < 36, 1,
        if([cpis_temp] < 38.5, 0,
          if([cpis_temp] < 39, 1,
            if([cpis_temp] < 41, 3, 4)
          )
        )
      )
    )
  )
)

If you can ask your local administrators to install the JavaScript injector External Module for you, you could code this up in JS much more easily and roll your own function to return the category from the input temperature.

Jangari
  • 690
  • 4
  • 12