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

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

Open
himeshr opened this issue Apr 13, 2023 · 1 comment

Comments

@himeshr
Copy link
Contributor

himeshr commented Apr 13, 2023

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
@himeshr
Copy link
Contributor Author

himeshr commented Apr 13, 2023

GroupedObservation Output JSON:
[{
groupObservations:
[{
that:
{
concept:
{
name: 'Task Assigned Status_Intern',
datatype: 'Coded',
uuid: '97e242a2-8f0e-4d82-b2fc-708a3c77cb65',
keyValues: [],
unit: null,
lowAbsolute: null,
lowNormal: null,
hiNormal: undefined,
hiAbsolute: undefined,
answers:
[{
uuid: 'a8cec34c-29f2-4a39-addc-3170096ed49d',
answerOrder: 2,
abnormal: false,
unique: false,
voided: false,
concept:
{
name: 'Delayed / Pending',
uuid: 'e06bb821-0bea-4923-8aa3-f6d8958d8905',
datatype: 'NA',
lowAbsolute: null,
hiAbsolute: undefined,
lowNormal: null,
hiNormal: undefined,
unit: null,
voided: false,
keyValues: [],
answers: []
}
},
{
uuid: 'e1046ebc-12a8-4021-9161-a6af36190d37',
answerOrder: 0,
abnormal: false,
unique: false,
voided: false,
concept:
{
name: 'Completed',
uuid: '9a07ba44-2b41-44c9-8fc7-adab74ecb752',
datatype: 'NA',
lowAbsolute: null,
hiAbsolute: undefined,
lowNormal: null,
hiNormal: undefined,
unit: null,
voided: false,
keyValues: [],
answers: []
}
},
{
uuid: '0481807e-c0c4-4db0-9695-26731651d1c1',
answerOrder: 1,
abnormal: false,
unique: false,
voided: false,
concept:
{
name: 'Going As Planned',
uuid: '93a7d4c8-a805-4203-878d-bed534c6f62c',
datatype: 'NA',
lowAbsolute: null,
hiAbsolute: undefined,
lowNormal: null,
hiNormal: undefined,
unit: null,
voided: false,
keyValues: [],
answers: []
}
}]
},
valueJSON: {answer: '93a7d4c8-a805-4203-878d-bed534c6f62c'}
}
},
{
that:
{
concept:
{
name: 'Date of Attendance',
datatype: 'Date',
uuid: 'f90c8c11-caad-4e05-abb0-a28ff8af5799',
keyValues: [],
unit: null,
lowAbsolute: null,
lowNormal: null,
hiNormal: undefined,
hiAbsolute: undefined,
answers: []
},
valueJSON:
{
value: '2023-04-10T18:30:00.000Z',
datatype: 'Date',
answer: "Tue Apr 11 2023 00:00:00 GMT+0530 (IST)"
}
}
}]
}]

@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
None yet
Projects
Status: In Analysis Review
Development

No branches or pull requests

2 participants