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

[avni-webapp] issue in displaying multi select answers #998

Open
Tracked by #1385
nupoorkhandelwal opened this issue Jul 7, 2023 · 3 comments
Open
Tracked by #1385

[avni-webapp] issue in displaying multi select answers #998

nupoorkhandelwal opened this issue Jul 7, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@nupoorkhandelwal
Copy link
Contributor

Describe the bug
When via rule if we try to populate answers of a multi select question based on the previous question's answers being selected - so when the first answer of this multi select is displayed is the only answer which is in auto select mode remains selected even if there are multiple answers getting displayed.

To Reproduce
Steps to reproduce the behavior:

  1. Go to apt uat
  2. Go to Observation Encounter
  3. Go to the last section "Fill in these details after the classroom observation"
  4. Scroll down to "Please select the different types of ICT that are present/accessible in the classroom"
  5. Now select any one answer to the above question - the answer selected makes the first answer to the next question - "Select the ICT in working condition" as auto selected
  6. Now if you select multiple answers to - "Please select the different types of ICT that are present/accessible in the classroom", it will keep the first answer in auto selected mode only.

Expected behavior
Ideally the answers to the "Please select the different types of ICT that are present/accessible in the classroom" should not come auto selected irrespective if it has multiple coded answers
https://images.zenhubusercontent.com/172675608/1f6884bb-435c-4a22-abe6-c3dd56600d83/ezgif_com_video_to_gif.mov

@nupoorkhandelwal nupoorkhandelwal added the bug Something isn't working label Jul 7, 2023
@vinayvenu
Copy link
Member

@nupoorkhandelwal can you please attach the rules that you used to achieve the above behaviour?

@nupoorkhandelwal
Copy link
Contributor Author

nupoorkhandelwal commented Sep 20, 2023

({params, imports}) => {
  const encounter = params.entity;
  const moment = imports.moment;
  const formElement = params.formElement;
  const _ = imports.lodash;
  let visibility = true;
  let value = null;
  let answersToSkip = [];
  let validationErrors = [];
  let ruleCondition = new imports.rulesConfig.RuleCondition({
        encounter
    });
  
  const condition11 = new imports.rulesConfig.RuleCondition({encounter, formElement}).when.valueInEncounter("788f5394-93ab-43a1-802e-a308bee7a298").containsAnswerConceptName("7fcfd8ea-f683-485f-ac40-ee8c303faaef").matches();
  
  const condition21 = new imports.rulesConfig.RuleCondition({encounter, formElement}).when.valueInEncounter("e565109c-36c7-4280-bbd7-fb015e502a3f").defined.matches();
  
  if (condition11 && condition21) {
    visibility =  true;
    const typesOfIctSelected =  encounter.getObservationReadableValue('e565109c-36c7-4280-bbd7-fb015e502a3f');
    console.log('typesOfIctSelected',typesOfIctSelected);
    const options = [
        "Interactive Flat Panel",
        "Smart TV",
        "Tablet",
        "KYAN/Projector",
        "Laptop",
        "Mobile Phone",
        "Others"
    ];
    if (typesOfIctSelected) {
       answersToSkip =  _.difference(options, typesOfIctSelected).map(answerName => formElement.getAnswerWithConceptName(answerName)) ;
        console.log('answersToSkip',JSON.stringify(answersToSkip));
     }
  }
  else {
    visibility =  false;
  }
  return new imports.rulesConfig.FormElementStatus(formElement.uuid, visibility, value, answersToSkip, validationErrors);
};

@mahalakshme
Copy link
Contributor

mentioned by Nupoor: work around was to add None as option to the answers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: New Issues
Development

No branches or pull requests

3 participants