You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For avoiding duplicate phone numbers beyond 5, the idea is to just add an API endpoint and call it from form element rule when user enters the mobile number
Requirement 2:
As part of Epic avniproject/avni-product#1507 and Story #1171, we encountered an issue while evaluating rules for Goonj organisation, for creation of Distribution.
We are linking Activities to a distribution, by doing a search and select of Subject. This is then used within FormElement rule to initialize certain fields. For this purpose, we make use of individualService.getSubjectByUUID() call in the rules.
(on distribution registration, activity's pariticipants will not get immediately populated after selecting an activity.)
RuleEvaluationService in webapp has a problem while fetching a different individual using its uuid.
The rule written for client, assumes that individualServiceFacade will always be able to fetch the individual in a synchronous manner, which works fine there as its connected to the realm DB. But on the web-app, we need to fetch the individual from the backendServer asynchronously as a remote call.
This results in 2 Major behaviourial changes:
Within any rule, whenever we need to fetch the Subject, we would need to figure out a way to handle the Promise returned by the async facade service fetch calls on the webapp, while simultaneously working correctly on the client in a synchronous manner.
Provide ability to invoke RuleEvaluationService in an asynchronous manner, to be able to invoke an async call and resolve it.
Acceptance Criteria
We are able to run the same FormElement rule which uses following services methods in both webapp and client.
In webapp after this change, soon after selection of activity in distribution registration, value for 'Total participants in the activity' field should get populated. Currently it gets populated only after entering value in some other field(ie., only after rule corresponding to 'Total participants in the activity' runs 2 times)
Tech Approach
Needs more Technical evaluation.
Current solutions for each of the above problem:
In this scenario, we could run a string replace query on the rule content to replace all "individualService.getSubjectByUUID(" with "await individualService.getSubjectByUUID(" in webapp at runtime.
Also, we need to make the rule function async by prefixing the keyword "async" only in webapp.
For this, we would prefer to only make the RuleEvaluation related entities data init, update and rule execution to be encapsulated within the FormWizard and run in Asynchronous manner, while rest of the Webapp working as is in a synchronous manner.
Additional Information
The list of impacted Orgs and Elements with rules that need asynchronous api calls is as per below attached file. InstancesOfRuleInDB.txt
AC:
Figure out the below:
Is supporting both sync and async execution of rules feasible at the same time/common code
Would it need update of existing rules in db and if yes, more details on the same.
How will execution of old rules get impacted
How many days will it take to complete the above if it is feasible.
The text was updated successfully, but these errors were encountered:
mahalakshme
changed the title
Handle Async fetch of related entities during Rule Evaluation in DEA
[DEA] Handle Async fetch of related entities during Rule Evaluation
Jun 13, 2024
Motivation
Requirement 1:
For avoiding duplicate phone numbers beyond 5, the idea is to just add an API endpoint and call it from form element rule when user enters the mobile number
Requirement 2:
As part of Epic avniproject/avni-product#1507 and Story #1171, we encountered an issue while evaluating rules for Goonj organisation, for creation of Distribution.
We are linking Activities to a distribution, by doing a search and select of Subject. This is then used within FormElement rule to initialize certain fields. For this purpose, we make use of individualService.getSubjectByUUID() call in the rules.
(on distribution registration, activity's pariticipants will not get immediately populated after selecting an activity.)
RuleEvaluationService in webapp has a problem while fetching a different individual using its uuid.
The rule written for client, assumes that individualServiceFacade will always be able to fetch the individual in a synchronous manner, which works fine there as its connected to the realm DB. But on the web-app, we need to fetch the individual from the backendServer asynchronously as a remote call.
This results in 2 Major behaviourial changes:
Acceptance Criteria
Service Methods
individualService.getSubjectByUUID
individualService.getSubjectsInLocation
addressLevelService.findAddressLevelByUUID
Tech Approach
Needs more Technical evaluation.
Current solutions for each of the above problem:
In this scenario, we could run a string replace query on the rule content to replace all "individualService.getSubjectByUUID(" with "await individualService.getSubjectByUUID(" in webapp at runtime.
Also, we need to make the rule function async by prefixing the keyword "async" only in webapp.
For this, we would prefer to only make the RuleEvaluation related entities data init, update and rule execution to be encapsulated within the FormWizard and run in Asynchronous manner, while rest of the Webapp working as is in a synchronous manner.
Additional Information
The list of impacted Orgs and Elements with rules that need asynchronous api calls is as per below attached file.
InstancesOfRuleInDB.txt
AC:
Figure out the below:
The text was updated successfully, but these errors were encountered: