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

Rule condition not working for repeatable question group #34

Open
mahalakshme opened this issue May 3, 2023 · 0 comments
Open

Rule condition not working for repeatable question group #34

mahalakshme opened this issue May 3, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mahalakshme
Copy link

mahalakshme commented May 3, 2023

Usecase:
In LAHI alumini profile encounter, want to calculate some of the statuses(Employed and Higher Technical Education) of "LAHI alumini status" based on value in a repeatable question group.

Issues:
The below doesn't work:
const condition15 = new imports.rulesConfig.RuleCondition({programEncounter, formElement}).when.valueInEncounter(childConceptUuid, parentConceptUuidOfQuestionGroup).containsAnswerConceptName(answerConceptValue).matches(); and

const condition12 = new imports.rulesConfig.RuleCondition({programEncounter, formElement}).when.valueInEncounter("07b7866f-1318-48f1-9cde-3720131575c1","a284be97-2fb7-44e7-9891-b90f166aa532").containsAnswerConceptName("f69d34d8-0316-43b7-b211-653b38ba69d8").matches();

Analysis:

  • The above didn't work since findObservation in avni-models, AbstractEncounter.js didn't handle for repeatable question group.

Hence currently, function like below is done:

const isObservationPresentInParentConcept = (valueConceptUuid, childConceptUuid, parentConceptUuidOrName) => {
    const obs = programEncounter.findObservation(parentConceptUuidOrName);
    const repeatableObservations = obs && obs.getValueWrapper() && obs.getValueWrapper().repeatableObservations;
    const condition12 = repeatableObservations && _.some(repeatableObservations, (repeatableObservation) => {
    const observation = repeatableObservation && repeatableObservation.findObservationByConceptUUID(childConceptUuid);
    const obsValue = observation && observation.getValue();  
    return (obsValue === valueConceptUuid);   
   }); 
   return condition12;
  }   

  const condition25 = _.some(["a06c3964-c2de-4ec4-ac12-5dda94122ade","9fee1da4-9002-49b0-a343-05490c073fb8"], 
   (valueConceptUuid) => isObservationPresentInParentConcept(valueConceptUuid, "30843b2e-37d8-459d-b0ae-f1feaa744cb0", "edb38ea2-9547-49ba-9d74-a84db74e4a4a"));

  • The below also cannot be done:
    const condition12 = new imports.rulesConfig.RuleCondition({programEncounter, formElement}).when.questionGroupValueInEncounter("07b7866f-1318-48f1-9cde-3720131575c1","a284be97-2fb7-44e7-9891-b90f166aa532", questionGroupIndex).containsAnswerConceptName("f69d34d8-0316-43b7-b211-653b38ba69d8").matches(); since need to iterate for each value(questionGroupIndex) in repeatable observations.

  • Need to Handle all cases where the values of repeatable question group could be multiple or empty

Significance of fixing this issue:

  • For projects that self-manage like LAHI, fixing this will make their work easier.
  • Code duplication in implementations
  • Slows down work of implementation
@mahalakshme mahalakshme added the bug Something isn't working label May 3, 2023
@vinayvenu vinayvenu moved this to New Issues in Avni Product Jun 15, 2023
@vinayvenu vinayvenu moved this from New Issues to Analysis Complete in Avni Product Jun 15, 2023
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: In Analysis Review
Development

No branches or pull requests

2 participants