avniproject / avni-webapp

Web application for management and data entry
https://avniproject.org
GNU Affero General Public License v3.0
9 stars 40 forks source link

Remove workaround for message rule #1260

Open mahalakshme opened 2 weeks ago

mahalakshme commented 2 weeks ago

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:

AC:

Testing:

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

1t5j0y commented 2 weeks ago

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]
    }
};
AchalaBelokar commented 4 days ago
1t5j0y commented 4 days ago

@AchalaBelokar testing this card does not require registration of a new subject. You can perform the 'LAHI INTERN ATTENDANCE' encounter on an existing subject.

AchalaBelokar commented 2 days ago