Is it possible to use <when> conditions on a boolean answer for HTML forms?

Hello everybody !

We are currently writing an HTML Form to collect Outpatient information from nurses. One of the Question in the form is CIEL:5703 : “Has the patient been hospitalized in the past year?” with Boolean answer type. If the nurse enters Yes, we would like to show the When, Where and Why fields.

Is that possible to use the <when> condition on a Boolean answer ?

I tried the following syntax :

<obs conceptId="CIEL:5703" id="previous-admission" style="yes_no_dropdown">
    <controls>
        <when value="true" thenDisplay="#previous-admission-yes" />
    </controls>
</obs>

And got :

org.codehaus.jackson.JsonGenerationException: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?)

Same with

<obs conceptId="CIEL:5703" id="previous-admission" style="yes_no_dropdown">
<controls>
    <when value="yes" thenDisplay="#previous-admission-yes" />
</controls>

Is there a correct syntax to use to test Boolean answers ? Or is that simply not supported by this markup ?

Thank you

Under the hood, boolean answers are stored as concepts. So try using “CIEL:1065”.

1 Like

Thanks Darius, I try that, but it still doesn’t work.

<obs conceptId="CIEL:5703" id="previous-admission" style="yes_no_dropdown">
    <controls>
        <when value="CIEL:1065" thenDisplay="#previous-admission-yes" />
    </controls>
</obs>

No error is returned this time when loading the form. But the the logic doesn’t run : When I select the “Yes” choice, nothing appears. Just to make sure, here is the code :

<p>
    <obs conceptId="CIEL:5703" id="previous-admission" style="yes_no_dropdown">
        <controls>
            <when value="CIEL:1065" thenDisplay="#previous-admission-yes" />
        </controls>
    </obs>
</p>
<span id="previous-admission-yes">
    <p>Your answer is Yes</p>
</span>

Hmm, try inspecting the html and see what code is the actual runtime value of the Yes choice.

Here is the HTML page source code :

<p>
    <span id="previous-admission" class="obs-field">
        <select id="w12" name="w12">
            <option value="" selected="true"></option>
            <option value="true">Yes</option>
            <option value="false">No</option>
        </select>
        <span class="error field-error" style="display: none" id="w11"></span>
    </span>
    <script type="text/javascript">
jQuery(function() { htmlForm.setupWhenThen('previous-admission', {"1065":"#previous-admission-yes"}, null, null); });
</script>
</p>
<span id="previous-admission-yes">
    <p>Your answer is Yes</p>
</span>

It seems that the runtime value of Yes is true. But I can’t use <when value=“true” thenDisplay…/> without throwing the error cited above.

Found how to solve it.

The getSubstitution() method in the WhenTagHandler.java class doesn’t handle values that are not Concepts. True and False answers (of Boolean datatype Concept) are not themselves concepts.

Created issue:

1 Like