Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xform rendering hides choices when relevance condition and choice filter are applied to a secondary question #5636

Closed
kitsao opened this issue May 3, 2019 · 20 comments · Fixed by #7256
Assignees
Labels
Enketo Affects Enketo forms Priority: 2 - Medium Normal priority Type: Bug Fix something that isn't working as intended
Milestone

Comments

@kitsao
Copy link

kitsao commented May 3, 2019

Describe the bug
Choices for a secondary select_one/select_multiple field do not show when both relevance condition and choice filter are applied. Consider the following design xls immunization section:

Question/Note/Label Type Required Choices Condition (Relevance/Show only if + Constraints/Validation)
Select the vaccines that were given on {{date}} Tick every condition/symptom that applies select_multiple yes BCG, Birth Polio (OPV 0), OPV, PCV, DPT-HepB-Hib, IPV, Rota, Vitamin A, Measles Don't show vaccines already reported. Birth Polio(OPV 0) if age <= 2weeks, OPV, PCV, Rota and DPT-HepB-Hib if age >= 6 weeks, Vit A if age >= 6 months, Measles if age >= 9 months
Select which dose of OPV was given on {{date}} select_one yes OPV 1/2/3 If OPV is selected. Show OPV 2 if age >= 10 weeks, OPV 3 if age >= 14 weeks. Don't show doses already reported.
Select which dose of PCV was given on {{date}} select_one yes PCV 1/2/3 If PCV is selected. Show PCV 2 if age >= 10 weeks, PCV 3 if age >= 14 weeks. Don't show doses already reported.
Select which dose of DPT-HepB-Hib was given on {{date}} select_one yes DPT-HepB-Hib 1/2/3 If DPT-HepB-Hib is selected. Show DPT-HepB-Hib 2 if age >= 10 weeks, DPT-HepB-Hib 3 if age >= 14 weeks. Don't show doses already reported.
Select which dose of Rota was given on {{date}} select_one yes Rota 1/2 If Rota is selected. Show Rota 2 if age >= 10 weeks. Don't show doses already reported.
Select which dose of Measles was given on {{date}} select_one yes Measles 1/2 If Rota is selected. Show Measles 2 if age >= 18 months. Don't show doses already reported.

To Reproduce
Steps to reproduce the behavior:

  1. Configure the above, a sample can be found here
  2. Convert and upload the form and pick a client profile to complete it
  3. The behavior in the image below is observed, doses do not show
    image

Expected behavior
The expected behavior is to have the doses (choices) showing appropriately, as shown below. This happens when I either remove the relevance condition or the choice filter.
image

Logs
No logs on browser console.

Screenshots
See captures above.

Environment

  • Instance: pih-malawi.dev.medicmobile.org
  • Browser: Chrome
  • Client platform: Linux
  • App: webapp
  • Version: 3.4.0

Additional context
This was experienced in 3.3.0 too. The workaround applied is merging vaccines and doses, i.e. instead of asking to select dose say for OPV, have vaccines as OPV 1, OPV 2 and OPV 3 ...

cc @derickl @smbuthia

Why Now?
Partner(s): Internal
Reason(s): A partner will have CHWs/Supervisors with a detrimental experience, thus providing bad care

@kitsao kitsao added the Type: Bug Fix something that isn't working as intended label May 3, 2019
@SCdF
Copy link
Contributor

SCdF commented May 7, 2019

Worked in 2.14 / 2.x (according to @derickl and @smbuthia). We should work out which version of Enketo broke this, and if it's been subsequently fixed in a later version.

@garethbowen garethbowen added the Priority: 2 - Medium Normal priority label May 22, 2019
@tookam tookam self-assigned this Aug 5, 2019
@tookam
Copy link
Contributor

tookam commented Aug 5, 2019

@kitsao Thanks for sharing the sample but it fails to load ..
Screen Shot 2019-08-05 at 4 03 15 PM

has the form been updated?
(pih-malawi.dev.medicmobile.org produces 502)

@garethbowen
Copy link
Member

Possibly related: #4249

@Hareet
Copy link
Member

Hareet commented Aug 6, 2019

@wtekeu
pih-malawi.dev.medicmobile.org is back up. Please check again.

@tookam
Copy link
Contributor

tookam commented Aug 20, 2019

@kitsao After doing some research, it looks like this is due to the use of the following skip logic:
<bind nodeset="/under_5_screening/vaccines_given/visit_details" relevant="../visits_reported != 0"/>
When you remove this line it does work. Can you think of an alternative way to build the skip logic?

@tookam tookam removed their assignment Aug 23, 2019
@abbyad
Copy link
Contributor

abbyad commented Sep 3, 2019

@wtekeu does it work with different relevant conditions, such as relevant="true()"?

@tookam
Copy link
Contributor

tookam commented Sep 9, 2019

@abbyad it does work but if you select Zero immunization to report then click on Next then back with Prev then select One immunization to report it does not work.

@tookam
Copy link
Contributor

tookam commented Sep 9, 2019

But when you remove the line, it works in both cases. The only drawback is that if you select Zero you get a blank page with just the title of the form and the buttons Prev, Next and the link Cancel

@abbyad
Copy link
Contributor

abbyad commented Sep 9, 2019

Are you confirming that a valid relevant statement doesn't work as expected? Is this related to our version of Enketo, or Enketo proper? It would be good for us to handle this rather than not using relevant statements.

@tookam tookam assigned tookam and vimemo and unassigned tookam Sep 9, 2019
@garethbowen
Copy link
Member

Bumped to 3.8.0 so it doesn't hold up the release.

@garethbowen
Copy link
Member

No update for some time. Bumping.

@craig-landry craig-landry modified the milestones: 3.13.0, 3.14.0 Sep 15, 2021
@jkuester jkuester modified the milestones: 3.14.0, 3.15.0 Jan 26, 2022
@mrjones-plip
Copy link
Contributor

@jkuester - can you tell if the enketo uplift in 4.0 will fix this? If yes, I'll move it there. Thanks!

@garethbowen
Copy link
Member

@jkuester Any update on this?

@jkuester
Copy link
Contributor

@garethbowen shoot! This fell off my radar somehow.

@kitsao, sorry to resurrect this ancient history, but I am having some trouble recreating this and was wondering if you could give me access to the Google xlsx form that you linked in the original issue (if it still exists). I have requested access via the link already. I tried cobbling together a form based on a combination of the PIH under_5_screening and immunization forms, but even the earliest versions of those forms in the medic repos appear to have already been refactored to fix the issue....

@jkuester
Copy link
Contributor

Okay, spoke too soon! I realized that my test form did not have anything set for the choice_filter. I am now able to recreate this behavior. TLDR is that this issue appears to have been fixed by the Enketo uplift!

Here is the most basic config that I have come up with that demonstrates the issue:

type name label::en relevant appearance choice_filter repeat_count
begin group my_group NO_LABEL   field-list    
integer question_count Repeat Count        
begin repeat my_repeat NO_LABEL ${question_count} != 0     ${question_count}
select_one yes_no my_question You should be able to see the choices true()   true()  
end repeat            
end group            

The best I can tell, what seems to be happening in the old version of Enketo is that the order of evaluations gets confused so the choice_filter value is not properly evaluated for questions inside a repeat when the repeat's relevant and repeat_count logic are both calculated (yeah the chain of dependencies here is mind-numbing).

This is what I see when running the above form on 3.4:
image

And this is what I see on 6345-enketo-uplift:
image

@garethbowen
Copy link
Member

Great! I'll move this issue to 4.0.0 to line up with the upgrade. Thanks.

@garethbowen garethbowen modified the milestones: 3.15.0, 4.0.0 Mar 16, 2022
@dianabarsan dianabarsan added the Enketo Affects Enketo forms label Apr 26, 2022
@jkuester
Copy link
Contributor

@medic/quality-assurance this issue is ready for AT on #7256

@garethbowen garethbowen moved this to Ready for AT in Product Team Activities Jul 31, 2022
@ngaruko ngaruko self-assigned this Aug 11, 2022
@ngaruko ngaruko moved this from Ready for AT to AT in Progress in Product Team Activities Aug 11, 2022
@jkuester
Copy link
Contributor

@tatilepizs here is the xml for a sample for that you can use to test this behavior:

<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms">
  <h:head>
    <h:title>Enketo Widgets</h:title>
    <model>
      <itext>
        <translation lang="en">
          <text id="/enketo_widgets/my_group/my_repeat/my_question:label">
            <value>You should be able to see the choices</value>
          </text>
          <text id="/enketo_widgets/my_group/question_count:label">
            <value>Repeat Count</value>
          </text>
          <text id="static_instance-yes_no-0">
            <value>Yes</value>
          </text>
          <text id="static_instance-yes_no-1">
            <value>No</value>
          </text>
          <text id="static_instance-yes_no-2">
            <value>Don't Know</value>
          </text>
          <text id="static_instance-yes_no-3">
            <value>Not Applicable</value>
          </text>
        </translation>
      </itext>
      <instance>
        <enketo_widgets id="enketo_widgets" prefix="J1!enketo_widgets!" delimiter="#" version="2022-08-16 00:00:00">
          <my_group>
            <question_count/>
            <my_repeat_count/>
            <my_repeat jr:template="">
              <my_question/>
            </my_repeat>
          </my_group>
          <meta tag="hidden">
            <instanceID/>
          </meta>
        </enketo_widgets>
      </instance>
      <instance id="contact-summary"/>
      <instance id="yes_no">
        <root>
          <item>
            <itextId>static_instance-yes_no-0</itextId>
            <name>yes</name>
          </item>
          <item>
            <itextId>static_instance-yes_no-1</itextId>
            <name>no</name>
          </item>
          <item>
            <itextId>static_instance-yes_no-2</itextId>
            <name>dk</name>
          </item>
          <item>
            <itextId>static_instance-yes_no-3</itextId>
            <name>na</name>
          </item>
        </root>
      </instance>
      <bind nodeset="/enketo_widgets/my_group/question_count" type="int"/>
      <bind nodeset="/enketo_widgets/my_group/my_repeat_count" type="string" readonly="true()" calculate=" /enketo_widgets/my_group/question_count "/>
      <bind nodeset="/enketo_widgets/my_group/my_repeat" relevant=" /enketo_widgets/my_group/question_count  != 0"/>
      <bind nodeset="/enketo_widgets/my_group/my_repeat/my_question" type="select1" relevant="true()"/>
      <bind nodeset="/enketo_widgets/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
    </model>
  </h:head>
  <h:body class="pages">
    <group appearance="field-list" ref="/enketo_widgets/my_group">
      <input ref="/enketo_widgets/my_group/question_count">
        <label ref="jr:itext('/enketo_widgets/my_group/question_count:label')"/>
      </input>
      <group ref="/enketo_widgets/my_group/my_repeat">
        <label ref="jr:itext('/enketo_widgets/my_group/my_repeat:label')"/>
        <repeat nodeset="/enketo_widgets/my_group/my_repeat" jr:count=" /enketo_widgets/my_group/my_repeat_count ">
          <select1 ref="/enketo_widgets/my_group/my_repeat/my_question">
            <label ref="jr:itext('/enketo_widgets/my_group/my_repeat/my_question:label')"/>
            <itemset nodeset="instance('yes_no')/root/item[true()]">
              <value ref="name"/>
              <label ref="jr:itext(itextId)"/>
            </itemset>
          </select1>
        </repeat>
      </group>
    </group>
  </h:body>
</h:html>

@tatilepizs tatilepizs self-assigned this Aug 16, 2022
@tatilepizs
Copy link
Contributor

Config: Default
Environment: Local with docker helper script
Platform: WebApp
Browser: Chrome


The file used to test was provided by @jkuester in this comment

Reproducible on Master

Options are not shown.

Desktop

image

Mobile

image

Fixed on 6345-enketo-uplift

Options are shown successfully.

Desktop

image

Mobile

image

@tatilepizs tatilepizs moved this from AT in Progress to Ready to Merge in Product Team Activities Aug 16, 2022
Repository owner moved this from Ready to Merge to Done in Product Team Activities Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enketo Affects Enketo forms Priority: 2 - Medium Normal priority Type: Bug Fix something that isn't working as intended
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.