XPath evaluation: cannot handle function 'If' error when trying to add hidden value

The goal of the hidden value for each rapid test type is to report on tests
that were performed and came back negative without placing additional
burden on the user to indicate those.

The current collection of test questions displays only if the user
indicates that rapid testing is needed during this visit. The questions are:

  1. positive_test_list: Select all rapid tests which had POSITIVE results
    (check box)
    1. hiv
    2. syphilis
    3. gonorrhea
    4. chlamydia
    5. malaria
    6. none_of_above
  2. tests_not_performed: Were any rapid tests NOT performed? (check box)
    1. hiv_not_performed
    2. syphilis_not_performed
    3. gonorrhea_not_performed
    4. chlamydia_not_performed
    5. malaria_not_performed
    6. all_tests_performed

Essentially, we want to have one hidden value per test type which indicates
deliberately whether or not that test was performed AND negative. To that
end, I attempted a hidden value called "chlamydia_done_negative," but when
I go to preview the form in the web browser (to test), I receive the error "internal
error handling request: <type
'org.javarosa.xpath.XPathUnhandledException'>:
org.javarosa.xpath.XPathUnhandledException: The problem was located in
calculate expression for /data/hiv_done_negative XPath evaluation: cannot
handle function 'If'". I'm certain this is just user error, so if anyone
could help me w/ my logic, I would be so grateful! See below:

If(not(selected(#form/positive_test_list, 'chlamydia') and
not(selected(#form/tests_not_performed, 'chlamydia_not_performed')) or
not(selected(#form/positive_test_list, 'chlamydia') and
selected(#form/tests_not_performed, 'all_tests_performed')) or
selected(#form/positive_test_list, 'none_of_above') and
not(selected(#form/tests_not_performed, 'chlamydia_not_performed')) or
selected(#form/positive_test_list, 'none_of_above') and
selected(#form/tests_not_performed, 'all_tests_performed')), 'yes', 'no')

This is intended to capture a test as negative if:

  1. the test was not marked positive and was not marked not-performed OR

  2. the test was not marked positive and the all_tests_performed check box
    was marked OR

  3. none_of_above was selected from positive_test_list and test was not
    marked not-performed OR

  4. none_of_above was selected from positive_test_list and all_tests_performed
    was selected from tests_not_performed

Hi Jessica,

Function names in our XPath engine are case-sensitive. Can you try
replacing 'If' with 'if'?

Hope that resolves your issue!

··· -- Phillip Mates Mobile Engineer at Dimagi

Thank you! That worked :slight_smile:

··· On Tuesday, October 18, 2016 at 10:00:22 AM UTC-4, pmates wrote: > > Hi Jessica, > > Function names in our XPath engine are case-sensitive. Can you try > replacing 'If' with 'if'? > > Hope that resolves your issue! > > -- > Phillip Mates > Mobile Engineer at Dimagi >