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

getEncounters() methods weird behavior #1389

Open
Gojo-Taqi opened this issue Dec 2, 2024 · 0 comments
Open

getEncounters() methods weird behavior #1389

Gojo-Taqi opened this issue Dec 2, 2024 · 0 comments

Comments

@Gojo-Taqi
Copy link

Gojo-Taqi commented Dec 2, 2024

Describe the bug
On calling the method 'getEncounter()' in a form_element rule, visit_schedule_rule, etc.

To Reproduce
Steps to reproduce the behavior:
I was trying to fetch a value from a general encounter and assign that value to a field in the registration.

  1. Call this method and check for the logs in the client and on the web app.
  2. You should see both of them return separate things.

Sample of code I was trying out

'use strict';
({params, imports}) => {
  const individual = params.entity;
  const moment = imports.moment;
  const formElement = params.formElement;
  const _ = imports.lodash;
  let visibility = true;
  let value = null;
  let answersToSkip = [];
  let validationErrors = [];
  
  let valueOfConceptFromEncounter = individual.getEncounters(true).filter(enc => enc.encounterType.name = 'General encounter').map( val => val.getObservationValue('c02c9e4d-cb1b-4a92-a4a7-a53a1a5e044b'));
  console.log('valueOfConceptFromEncounter--------->',valueOfConceptFromEncounter);

  if (valueOfConceptFromEncounter) value = valueOfConceptFromEncounter[0];
  return new imports.rulesConfig.FormElementStatus(formElement.uuid, visibility, value, answersToSkip, validationErrors);
};

Expected behavior
When calling this method, the rule should behave consistently on the client as well as on the web app.

@Gojo-Taqi Gojo-Taqi moved this to New Issues in Avni Product Dec 2, 2024
@mahalakshme mahalakshme moved this from New Issues to Triaged in Avni Product Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triaged
Development

No branches or pull requests

1 participant