Remove workaround for message rule
Closed this issue · 5 comments
Need:
With the below, we will be supporting DEA for LAHI as well as per their need. Since currently from the decision rule of program encounter we can't access individual. Hence 'lahi intern attendance' decision rule is throwing 400.
Context:
- The decisions LAHI_TEAMS, Name and Date of Attendance are saved when saving 'LAHI INTERN ATTENDANCE Encounter' form. This was done because programEnrolment and group observations were not accessible from programEncounter before in message rule. Now it is accessible.
AC:
- Remove saving of the decisions in the 'LAHI INTERN ATTENDANCE Encounter' form
- Calculate those values directly in message rule of the LAHI INTERN ATTENDANCE encounter type without affecting its functionality.
- Make the above change in prerelease and comment in the card.
- Once the QA is done, we can move it to prod.
Testing:
- Check if sending message is working on saving of LAHI INTERN ATTENDANCE Encounter.
- Check if everything is working in DEA of LAHI
Analysis notes: (Can ignore)
Analysis Context:
The workarounds done(to make glific message working) to find enrolment observations and group observations in decisions rule can be moved to message rule here - https://app.avniproject.org/#/appDesigner/encounterType/1814/show since the below cards are released as part of 3.39 release:
avniproject/avni-models#43
avniproject/avni-server#529
Decision rule commented out. /web/rules
call continues to return a 400. To be looked at separately.
Updated message rule:
'use strict';
({params, imports}) => {
const programEncounter = params.entity;
const moment = imports.moment;
//let dateTime = programEncounter.getObservationReadableValue("Date of Attendance");
const groupedObservations = programEncounter.findGroupedObservation("Attendance Day");
const groupObservations = _.isEmpty(groupedObservations) ? [] : groupedObservations[0].groupObservations;
const dateTime = _.find(groupObservations, (observation) => {
return (observation.concept.name === "Date of Attendance");
});
const date = moment(dateTime).format("ll");
//console.log('enrolment====>',programEncounter.programEnrolment);
//const team = programEncounter.getObservationReadableValue("LAHI_TEAMS")[0];
const team = programEncounter.programEnrolment.getObservationReadableValue("LAHI_TEAMS")[0];
const individual = programEncounter.programEnrolment.individual;
const name = individual.name || individual.firstName + ' ' + individual.lastName;
//console.log(name, date, team);
return {
parameters: [name, 'Internship LAHI', date, team]
}
};
- Not able to test this card on webapp because of this card blocked #1269
@AchalaBelokar testing this card does not require registration of a new subject. You can perform the 'LAHI INTERN ATTENDANCE' encounter on an existing subject.
- Tested with lahi intern attendance form but still message is not sending
- and also check with boardcast feature that is alos not working.
Prod deployment notes
I. Removed this from "LAHI INTERN ATTENDANCE Encounter" "Decision Rule" section:
URL: https://app.avniproject.org/#/appdesigner/forms/13108280-bf04-4661-a126-9c7fcd5a1087
//SAMPLE RULE EXAMPLE
"use strict";
({params, imports}) => {
const programEncounter = params.entity;
const decisions = params.decisions;
const team_value = programEncounter.programEnrolment.getObservationReadableValue("LAHI_TEAMS");
const ind_name = programEncounter.programEnrolment.individual.name;
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");
});
decisions.encounterDecisions.push({name : "LAHI_TEAMS", value : team_value});
decisions.encounterDecisions.push({name : "Name", value : ind_name});
decisions.encounterDecisions.push({name : "Date of Attendance", value : dateOfAttendance.getValue()});
return decisions;
};
II. Added below to "LAHI INTERN ATTENDANCE Encounter" "Message Rule" section:
https://app.avniproject.org/#/appDesigner/encounterType/1814/show
//SAMPLE RULE EXAMPLE
'use strict';
({params, imports}) => {
const programEncounter = params.entity;
const moment = imports.moment;
//let dateTime = programEncounter.getObservationReadableValue("Date of Attendance");
const groupedObservations = programEncounter.findGroupedObservation("Attendance Day");
const groupObservations = _.isEmpty(groupedObservations) ? [] : groupedObservations[0].groupObservations;
const dateTime = _.find(groupObservations, (observation) => {
return (observation.concept.name === "Date of Attendance");
});
const date = moment(dateTime).format("ll");
//console.log('enrolment====>',programEncounter.programEnrolment);
//const team = programEncounter.getObservationReadableValue("LAHI_TEAMS")[0];
const team = programEncounter.programEnrolment.getObservationReadableValue("LAHI_TEAMS")[0];
const individual = programEncounter.programEnrolment.individual;
const name = individual.name || individual.firstName + ' ' + individual.lastName;
//console.log(name, date, team);
return {
parameters: [name, 'Internship LAHI', date, team]
}
};