We are currently working on the forum. For the short-term, all forum content will be in read-only format. We apologize for the interruption and look forward to collaborating with you shortly. All the best in your research!

Math in rules

Hey Folks -
I have another rules question. One of our customers has asked if we can do some math based on answers from a form. There are a series of 20 questions with 4 radio buttons each. Each radio button is given a number 0,1, 2, or 3. They want us to add the numbers up and give the total. So if they answered all 3 the total would be 60.
What I'm trying to do is use InsertAction and ValueExpression to do this. But, I'm starting to think it can't be done. There doesn't seem to be any documentation about ValueExpression, the docs just mention it's existence. So, is what I need to do possible? If so, how? I have tried many iterations, below is my most recent attempt. I appreciate all the help folks, you all are amazing!


I_RANDO_RIGNORE





(SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESBOTHERED_1229 + SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESAPPETITE_2255)






Check to see if patient answered the CESD questions

(SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESBOTHERED_1229 gte 0)
and (SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESAPPETITE_2255 gte 0)



-Brian

Comments

  • lindsay.stevenslindsay.stevens Posts: 404 ✭✭✭
    Hi Brian,
    It is not possible at the moment; arithmetic for insertactions has been in the feature request queue for a year or so I think. Currently you can insert a static value using the Value attribute of DestinationProperty, or exactly copy an existing value using ValueExpression, as noted at [1].
    Since it sounds like all your items are on the same CRF, you can probably just use a calculated field. Check the instructions tab of the CRF template, the syntax is like func: sum(item1,item2,item3). The main/worst hitch with calculation items is that if any of the items in the expression are blank, the calculation won't work. This could be mitigated somewhat by using non-null default values.
    Some more insertaction info that might save you some time / be of interest:
    1. Action models at [2], basically:
    - non-repeating item or specified row of repeating item or static value -> non-repeating item
    - non-repeating item or specified row of repeating item or static value -> first row of repeating item if no target row specified, or specified row of repeating item (if target row is >1 and prior rows don't exist, they are added and blank)
    I have a vague recollection that you can also duplicate a repeating group but you'd need to check that.
    2. A previous rant about the behaviour of insertaction rules at [3].
    [1] https://docs.openclinica.com/3.1/rules/creating-rules#content-title-4604
    [2] https://docs.openclinica.com/3.1/rules/rule-action-models
    [3] https://mailman.openclinica.com/pipermail/users/2013-February/008058.html
    Best regards,
    Lindsay
    On 18 October 2013 21:00, Brian Johnson wrote:
    Hey Folks -
    I have another rules question. One of our customers has asked if we can do some math based on answers from a form. There are a series of 20 questions with 4 radio buttons each. Each radio button is given a number 0,1, 2, or 3. They want us to add the numbers up and give the total. So if they answered all 3 the total would be 60.
    What I'm trying to do is use InsertAction and ValueExpression to do this. But, I'm starting to think it can't be done. There doesn't seem to be any documentation about ValueExpression, the docs just mention it's existence. So, is what I need to do possible? If so, how? I have tried many iterations, below is my most recent attempt. I appreciate all the help folks, you all are amazing!


    I_RANDO_RIGNORE





    (SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESBOTHERED_1229 + SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESAPPETITE_2255)






    Check to see if patient answered the CESD questions

    (SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESBOTHERED_1229 gte 0)
    and (SE_INTAKESURVEY.F_BLJ_INTAKE03_16.IG_BLJ_I_UNGROUPED_7738.I_BLJ_I_INTCESAPPETITE_2255 gte 0)



    -Brian
This discussion has been closed.