Skip to content

Unable to retreive RepeatableQuestionGroup Observation concept value for a ProgramEncounter #42

@himeshr

Description

@himeshr

In "Lend a hand India" org, for "LAHI Intern" Subject, "Internship LAHI" Program, "LAHI INTERN ATTENDANCE" Program Encounter is to be created.

As part of the ProgramEncounter's Decision rule, we need to fetch "Date of Attendance" concept value from within the "Attendance Day" RepeatableQuestionGroup's groupObservations.

Attempting this results in failure, as following method fails to handle the array nature of "Attendance Day" RepeatableQuestionGroup :

const dateOfAttendance = programEncounter.findObservation("Date of Attendance","Attendance Day");
**ERROR: undefined is not an object (evaluating 't.concept.name')**

In avni-models, AbstractEncounter.js:

  findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
    const observations = _.isNil(parentConceptNameOrUuid) ? this.observations : this.findGroupedObservation(parentConceptNameOrUuid);
    return _.find(observations, (observation) => {
      return (observation.concept.name === conceptNameOrUuid) || (observation.concept.uuid === conceptNameOrUuid);
    });
  }

ERROR is at "(observation.concept.name === conceptNameOrUuid)".. observation.concept is undefined.

Instead, we should fetch the value from the first entry in RepeatableQuestionGroup as follows:

const groupedObservations = programEncounter.findGroupedObservation("Attendance Day");
  const groupObservations = _.isEmpty(groupedObservations) ? [] : groupedObservations[0].groupObservations;
  const dateOfAttendance =  _.find(groupObservations, (observation) => {
    return (observation.concept.name === "Date of Attendance");
  });

Tech tasks:

  • Handle fetch value of a concept from RepeatableQuestionGroup Observations
    I. for all repetition in RepeatableQuestionGroup
    II. for a single repetition in RepeatableQuestionGroup
    III. for specific repetition in RepeatableQuestionGroup based on some filter criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Analysis Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions