Skip to content

Rule Builder fails with 'Cannot read property 'findObservation' of undefined' #1606

@adamsanadi6

Description

@adamsanadi6

Describe the bug

Rule build using the rule builder is failing with error: "Cannot read property 'findObservation' of undefined". The issue occurs because in RuleCondition, an individual object is being passed to the context instead of a programEncounter object while trying to write Program Encounter Eligibility Rule.

To Reproduce

  1. Go to the Program Encounte Eligibility.
  2. Create a rule using the rule builder on the Program Enrolment.
  3. Save and test the rule.
  4. Rule fails with the error message.

Expected behavior

Rule should build successfully and execure.

Root Cause Analysis

  1. The rule appears to be failing while trying to execute _obsFromEnrolment method in RuleCondition.js file
  2. In _obsFromEnrolment method enrolment is undefined and it is trying to call findObservation on this undefined object.
  3. The enrolment object is undefined because The _getEnrolment is returning undefined.
  4. Because of this the rule is failing, by stating "Cannot read property 'findObservation' of undefined".

Screenshots

  1. Eligibility Rule:
Image Image 2. Rule Failure Telemetry: Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions