Closed mahalakshme closed 1 year ago
@mahalakshme can you add the Freshdesk ticket related to this?
During testing, found that, during messageRule execution, we are now capable of extracting observation from a repeatableQuestionGroup. But, in-order to test ability to fetch QuestionGroup observation during MessageRule execution, i created a new Encounter with messageRule and Schedule rule. Here, i'm unable to get the ScheduleRule to execute successfully.
2023-08-11 14:09:27.955 ERROR 2382 --- [http-nio-8021-exec-12] o.a.messaging.service.MessagingService : Missing Schedule dateTime in message rule template Inter_att_single
'use strict'; ({params, imports}) => { const programEncounter = params.entity; var scheduledDate = programEncounter.encounterDateTime; console.log('enrolment====>',programEncounter.enrolment); return {scheduledDateTime: scheduledDate} };
0|rules-server | Headers from req: maha@lahi eyJraWQiOiJqQlZHUU9sTzVKaGIyUWJ1R3NvZlZwTWlEdjFmTlh3bmFscU1xTXo2ZitnPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJhZWY4MTA0NC04YjY4LTQyMjItODAxOS00NGJlYWYzMGE0OTgiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmFwLXNvdXRoLTEuYW1hem9uYXdzLmNvbVwvYXAtc291dGgtMV9EVTI3QUhKdloiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOnRydWUsImNvZ25pdG86dXNlcm5hbWUiOiJtYWhhQGxhaGkiLCJjdXN0b206dXNlclVVSUQiOiIwZTY4ZmVjNS0zNGM0LTQ4ZTYtOWEzMC05NDgyNTJlNmViZmUiLCJhdWQiOiIxZDZyZ3ZpdGpzZm9vbmxrYm0wN3VpdmdtZyIsImV2ZW50X2lkIjoiMTI0MjU3ODgtMjg3MC00MmJlLTk3NDQtODVlNTZlYjc4M2E4IiwidG9rZW5fdXNlIjoiaWQiLCJhdXRoX3RpbWUiOjE2OTE3NTczMTAsInBob25lX251bWJlciI6Iis5MTk3OTEyMTcwNzgiLCJleHAiOjE2OTE3NjQ2NDUsImlhdCI6MTY5MTc2MTA0NSwiZW1haWwiOiJtYWhhQG1haWwuY29tIn0.eens6-ys7rqtd0mJo-VfR1043ZFM5GhKdLvi9tKLTeSW14xCdjOqDZEca11ABUzh-dnHzTrcKoM5WqILe7gcestl3chq-xWcz9NwFbseGTcL4JUByJQ4yLF0p5PBUvojd8YRIDcwsUtljAhW4CZrCVNsu2PGS1Z9WVR_Qks72esSzmstBsGTQPfb3aG6hFyO9j8f9DNH_qeSPiv3GmK3eA3GaCvhe8pydhkKZcZnuofs_UzL9xt4rvM8H1bAY9n7AQtUfhUJvAtPc4ttyRirPUJI60lv_6tXcWYLpwXAagcTBtLi4C594fZkHoAr31oHa2B7BXY-KHyJX6Vnqrd06Q 28dac619-c6b5-4e57-9bf9-58acd7da18e0 0|rules-server | TypeError: Cannot read property 'name' of undefined 0|rules-server | at Function.fromResource (/opt/rules-server/node_modules/openchs-models/dist/Concept.js:121:36) 0|rules-server | at Function.constructConceptModel (/opt/rules-server/node_modules/openchs-models/dist/observation/QuestionGroup.js:63:38) 0|rules-server | at concept.answers._lodash.default.map.answer (/opt/rules-server/node_modules/openchs-models/dist/observation/QuestionGroup.js:71:47) 0|rules-server | at arrayMap (/opt/rules-server/node_modules/lodash/lodash.js:639:23) 0|rules-server | at Function.map (/opt/rules-server/node_modules/lodash/lodash.js:9554:14) 0|rules-server | at Function.constructConceptModel (/opt/rules-server/node_modules/openchs-models/dist/observation/QuestionGroup.js:68:41) 0|rules-server | at _lodash.default.map (/opt/rules-server/node_modules/openchs-models/dist/observation/QuestionGroup.js:52:43) 0|rules-server | at arrayMap (/opt/rules-server/node_modules/lodash/lodash.js:639:23) 0|rules-server | at Function.map (/opt/rules-server/node_modules/lodash/lodash.js:9554:14)
Org : Lend a Hand India Env: pre-release Encounters: Single Question Group: https://prerelease.avniproject.org/#/appDesigner/encounterType/2118/show Repeatable Question Group: https://prerelease.avniproject.org/#/appDesigner/encounterType/1814/show
Second Error observed while executing message rule is:
0|rules-server | Headers from req: saeed@lahi undefined 28dac619-c6b5-4e57-9bf9-58acd7da18e0 0|rules-server | HR>>>>>>dateOfAttendance 2023-04-25T18:30:00.000Z 0|rules-server | HR>>>>>>result { parameters: 0|rules-server | [ '**test', 0|rules-server | 'Internship LAHI', 0|rules-server | 'Apr 26, 2023', 0|rules-server | 'Karigar - School of Applied Learning' ] }
2023-08-11 14:19:52.238 ERROR 2382 --- [pool-5-thread-1] o.a.messaging.external.GlificRestClient : Error while calling Glific API: /api 2023-08-11 14:19:52.238 ERROR 2382 --- [pool-5-thread-1] o.a.messaging.external.GlificRestClient : Request is {"query":"mutation sendHsmMessage($templateId: ID!, $receiverId: ID!, $parameters: [String]) {sendHsmMessage(templateId: $templateId, receiverId: $receiverId, parameters: $parameters) {message{id body isHsm } errors {key message } } }","variables":{"templateId":61881,"receiverId":907895,"parameters":[]}} 2023-08-11 14:19:52.238 ERROR 2382 --- [pool-5-thread-1] o.a.messaging.external.GlificRestClient : Response is GlificResponse{data=org.avni.messaging.contract.glific.GlificMessageResponse@413e5868, errors=[GlificError{locations=[GlificErrorLocation{column=85, row=0}], message='Please provide the right number of parameters for the template.'}]} 2023-08-11 14:19:52.238 ERROR 2382 --- [pool-5-thread-1] o.a.messaging.service.MessagingService : Could not send message for message request id: 167
org.avni.messaging.domain.exception.GlificConnectException: Please provide the right number of parameters for the template.
at org.avni.messaging.external.GlificRestClient.makeCall(GlificRestClient.java:78)
at org.avni.messaging.external.GlificRestClient.callAPI(GlificRestClient.java:62)
at org.avni.messaging.external.GlificRestClient.callAPI(GlificRestClient.java:51)
at org.avni.messaging.repository.GlificMessageRepository.sendMessageToContact(GlificMessageRepository.java:23)
at org.avni.messaging.repository.GlificMessageRepository$$FastClassBySpringCGLIB$$2dad3d0f.invoke(
@himeshr Single Question group had an issue with message rule: we were doing getValue on the value returned by getObservationValue. After removing getValue() it started working. Removed it since getObservationValue will already do getValue() internally.
repeatable question group is working without me making any changes. I just deleted all the requests whose status is anything other than 'Sent' to clear up the logs from unnecessary exceptions.
@himeshr tested the code with schedule rule having multi-line JS - the code that was there before - it is working.
Moved the card back to QA Failed, as we are still experiencing the error:
2023-08-17 04:49:14.711 ERROR 19538 --- [http-nio-8021-exec-4] o.a.messaging.service.MessagingService : Missing Schedule dateTime in message rule template Inter_att_single
Due to which Msg isnt getting scheduled for being sent out.
Need to review this commit alone in avni-server: 3400d2 cc: @himeshr
cherry-picked the commit from master to 4.0 branch in avni-server
issue raised by himesh was happening since single/multi select element values were not suppoerted in QG/RQG
During testing, i'm unable to save messageRequests due to following exception for both repeatable and non-repeatable question groups:
Tested on pre-release environment with 4.1 server and client.
Need to review this commit alone: da74685dce2a8f146b4d059033de0286312426b7 in server.
The issue was because coded concepts computed via decision rule, are saved in an array. But normally they are not saved as array when singleselect form element used. So made the check in the above commit specific to QuestionGroup, so that if any other concept has array values, it will not get affected.
Validated that it works for I. Program-encounter with a. repeatable question-group with single code-concept b. non-repeatable question-group with single code-concept II. General encounter with a. non-repeatable question-group with Single as well as Multi code-concepts
fix and testing were done in 4.1 by mistake and hence this ticket: cherrypick done to 4.0 branch.
Issue: For question group concepts, model functions doesn't execute as expected in message rule
Ticket: https://avni.freshdesk.com/a/tickets/2518 - workaround for this issue was done by using the model function in decision rule here
Steps to reproduce:
Expectation:
let dateTime = programEncounter.getObservationValue("Date of Attendance", "Attendance Day");
andin message rule should return date as expected.
Analysis: Printing the observations in decision rule vs in message rule:
looks like observations when sent from server to rule-server to execute message rule is not handled for group observations but in client since the data is accessible it works in decision rule.