avniproject / avniproject/rules-config
Rule failures happening for autogenerated rules
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Consider the encounter eligibility rule that is autogenerated
```
'use strict';
({params, imports}) => {
const individual = params.entity;
const moment = imports.moment;
let eligibility = true;
const condition11 = new imports.rulesConfig.RuleCondition({individual}).when.valueInEnrolment("97f801a6-343b-4d03-a1d5-fc80c4e01035").containsAnswerConceptName("87c7e983-93c8-4efe-be44-8a57534fce53").matches();
eligibility = condition11 ;
return eligibility;
};
```
This rule fails if the subject is not enrolled into a program with the following error.
```
TypeError: Cannot read property 'findObservation' of undefined at _obsFromEnrolment (address at index.android.bundle:1:1862338) at anonymous (address at index.android.bundle:1:1864492) at run (address at index.android.bundle:1:1961127) at anonymous (address at index.android.bundle:1:1862243) at run (address at index.android.bundle:1:1961127) at noop (address at index.android.bundle:1:1961030) at run (address at index.android.bundle:1:1961127) at execute (address at index.android.bundle:1:1960601) at matches (address at index.android.bundle:1:1863519) at anonymous (JavaScript:7:219) at isEligibleForEncounter (address at index.android.bundle:1:1731448) at anonymous (address at index.android.bundle:1:2552864) at filter (native) at onLoad (address at index.android.bundle:1:2552339) at anonymous (address at index.android.bundle:1:2491805) at combination (address at index.android.bundle:1:2632287) at dispatch (address at index.android.bundle:1:2631391) at dispatchAction (address at index.android.bundle:1:1256076) at UNSAFE_componentWillMount (address at index.android.bundle:1:4014184) at mountClassInstance (address at index.android.bundle:1:353180) at updateClassComponent (address at index.android.bundle:1:367330) at beginWork$1 (address at index.android.bundle:1:399679) at performUnitOfWork (address at index.android.bundle:1:386728) at workLoopSync (address at index.android.bundle:1:386630) at renderRootSync (address at index.android.bundle:1:386514) at performSyncWorkOnRoot (address at index.android.bundle:1:383997) at flushSyncCallbacks (address at index.android.bundle:1:349029) at batchedUpdatesImpl (address at index.android.bundle:1:400453) at batchedUpdates (address at index.android.bundle:1:341886) at _receiveRootNodeIDEvent (address at index.android.bundle:1:342159) at receiveTouches (address at index.android.bundle:1:395309) at apply (native) at __callFunction (address at index.android.bundle:1:98003) at anonymous (address at index.android.bundle:1:96496) at __guard (address at index.android.bundle:1:97436) at callFunctionReturnFlushedQueue (address at index.android.bundle:1:96454)
```
**Expected:** Rule failures should not happen for autogenerated rules
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the autogenerated encounter eligibility rule with a subject who is not enrolled, then trace the failure from matches through isEligibleForEncounter to _obsFromEnrolment. Verify the behavior around the missing enrolment context and confirm that evaluating the rule no longer raises the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100