Complex Hidden Values Formula Not Working

Hi everyone, I designed a simple survey-style app for prenatal care visits
in rural Haiti. In an effort to cut down on questions asking similar
information, part of the app asks the following two questions, and relies
on hidden fields to determine if a test was done with a negative result.

  1. Which rapid tests were positive? (positive_test_list) - this is a
    checkbox question
    -hiv
    -syphilis
    -gonorrhea
    -chlamydia
    -malaria
    -none_of_above

  2. Which rapid tests were not done? (tests_not_performed) - this is a
    checkbox question
    -hiv_not_performed
    -syphilis_not_performed
    -gonorrhea_not_performed
    -chlamydia_not_performed
    -malaria_not_performed
    -all_tests_performed

The hidden fields include:
-hiv_done_negative
-syphilis_done_negative
-gonorrhea_done_negative
-chlamydia_done_negative
-malaria_done_negative

Here is my formula, using HIV as an example:

if((not(selected( positive_test_list, 'hiv') and not(selected( tests_not_performed,
'hiv_not_performed'))) or not(selected( positive_test_list, 'hiv') and
selected( tests_not_performed, 'all_tests_performed')) or (selected( positive_test_list,
'none_of_above') and not(selected( tests_not_performed,
'hiv_not_performed'))) or (selected( positive_test_list, 'none_of_above')
and selected( tests_not_performed, 'all_tests_performed'))), 'yes', 'no')

The problem I am having is that the hidden values are not accurately
determining whether the test are done+negative or not. Every cell under
"hiv_done_negative" says "yes," even if the test was marked as not having
been performed. Because they are checkbox questions, often multiple answers
are selected for "tests_not_performed," and so I am wondering if this is
the issue. If it is, I think the formula would be incredibly complex
because it would have to account for all possible combinations of checkbox
answers. In that case, I would appreciate advice on how to restructure the
questions to avoid this at all. The providers using the app are quick
enough at this point that adding a question or two would not make it too
cumbersome.

Any insight is appreciated! Thanks!

Hello,

One idea is that the "all_tests_performed" answers and "none_of_above"
answers seem to be redundant answers as users can simply not select
anything from those checklists in those events. Removing these values
should greatly simplify your logic. For example hiv_done_negative becomes:

if(not(selected(positive_test_list, 'hiv') and
not(selected(tests_not_performed, 'hiv'), 'yes', 'no')

Cheers,
Will

··· On Tue, Dec 20, 2016 at 10:09 AM, wrote:

Hi everyone, I designed a simple survey-style app for prenatal care visits
in rural Haiti. In an effort to cut down on questions asking similar
information, part of the app asks the following two questions, and relies
on hidden fields to determine if a test was done with a negative result.

  1. Which rapid tests were positive? (positive_test_list) - this is a
    checkbox question
    -hiv
    -syphilis
    -gonorrhea
    -chlamydia
    -malaria
    -none_of_above

  2. Which rapid tests were not done? (tests_not_performed) - this is a
    checkbox question
    -hiv_not_performed
    -syphilis_not_performed
    -gonorrhea_not_performed
    -chlamydia_not_performed
    -malaria_not_performed
    -all_tests_performed

The hidden fields include:
-hiv_done_negative
-syphilis_done_negative
-gonorrhea_done_negative
-chlamydia_done_negative
-malaria_done_negative

Here is my formula, using HIV as an example:

if((not(selected( positive_test_list, 'hiv') and not(selected( tests_not_performed,
'hiv_not_performed'))) or not(selected( positive_test_list, 'hiv') and
selected( tests_not_performed, 'all_tests_performed')) or (selected( positive_test_list,
'none_of_above') and not(selected( tests_not_performed,
'hiv_not_performed'))) or (selected( positive_test_list, 'none_of_above')
and selected( tests_not_performed, 'all_tests_performed'))), 'yes', 'no')

The problem I am having is that the hidden values are not accurately
determining whether the test are done+negative or not. Every cell under
"hiv_done_negative" says "yes," even if the test was marked as not having
been performed. Because they are checkbox questions, often multiple answers
are selected for "tests_not_performed," and so I am wondering if this is
the issue. If it is, I think the formula would be incredibly complex
because it would have to account for all possible combinations of checkbox
answers. In that case, I would appreciate advice on how to restructure the
questions to avoid this at all. The providers using the app are quick
enough at this point that adding a question or two would not make it too
cumbersome.

Any insight is appreciated! Thanks!

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Will, thanks for your response. That is a good idea. A concern of mine
is that I wouldn't know if the question was answered or not.

··· On Tuesday, December 20, 2016 at 10:49:51 AM UTC-5, William Pride wrote: > > Hello, > > One idea is that the "all_tests_performed" answers and "none_of_above" > answers seem to be redundant answers as users can simply not select > anything from those checklists in those events. Removing these values > should greatly simplify your logic. For example hiv_done_negative becomes: > > if(not(selected(positive_test_list, 'hiv') and > not(selected(tests_not_performed, 'hiv'), 'yes', 'no') > > Cheers, > Will > > On Tue, Dec 20, 2016 at 10:09 AM, <monitoringe...@gmail.com > wrote: > >> Hi everyone, I designed a simple survey-style app for prenatal care >> visits in rural Haiti. In an effort to cut down on questions asking similar >> information, part of the app asks the following two questions, and relies >> on hidden fields to determine if a test was *done with a negative result* >> . >> >> 1. Which rapid tests were *positive*? (positive_test_list) - this is a >> checkbox question >> -hiv >> -syphilis >> -gonorrhea >> -chlamydia >> -malaria >> -none_of_above >> >> 2. Which rapid tests were *not done*? (tests_not_performed) - this is a >> checkbox question >> -hiv_not_performed >> -syphilis_not_performed >> -gonorrhea_not_performed >> -chlamydia_not_performed >> -malaria_not_performed >> -all_tests_performed >> >> The hidden fields include: >> -hiv_done_negative >> -syphilis_done_negative >> -gonorrhea_done_negative >> -chlamydia_done_negative >> -malaria_done_negative >> >> Here is my formula, using HIV as an example: >> >> if((not(selected( positive_test_list, 'hiv') and not(selected( tests_not_performed, >> 'hiv_not_performed'))) or not(selected( positive_test_list, 'hiv') and >> selected( tests_not_performed, 'all_tests_performed')) or (selected( positive_test_list, >> 'none_of_above') and not(selected( tests_not_performed, >> 'hiv_not_performed'))) or (selected( positive_test_list, >> 'none_of_above') and selected( tests_not_performed, >> 'all_tests_performed'))), 'yes', 'no') >> >> The problem I am having is that the hidden values are not accurately >> determining whether the test are done+negative or not. Every cell under >> "hiv_done_negative" says "yes," even if the test was marked as not having >> been performed. Because they are checkbox questions, often multiple answers >> are selected for "tests_not_performed," and so I am wondering if this is >> the issue. If it is, I think the formula would be incredibly complex >> because it would have to account for all possible combinations of checkbox >> answers. In that case, I would appreciate advice on how to restructure the >> questions to avoid this at all. The providers using the app are quick >> enough at this point that adding a question or two would not make it too >> cumbersome. >> >> Any insight is appreciated! Thanks! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "commcare-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >