Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workaround for message rule #1260

Closed
Tracked by #1629 ...
mahalakshme opened this issue Jun 19, 2024 · 5 comments
Closed
Tracked by #1629 ...

Remove workaround for message rule #1260

mahalakshme opened this issue Jun 19, 2024 · 5 comments
Assignees

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Jun 19, 2024

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

@mahalakshme mahalakshme converted this from a draft issue Jun 19, 2024
@mahalakshme mahalakshme moved this from In Analysis to Ready in Avni Product Jun 19, 2024
@1t5j0y 1t5j0y moved this from Ready to In Progress in Avni Product Jun 20, 2024
@1t5j0y 1t5j0y self-assigned this Jun 20, 2024
@mahalakshme mahalakshme moved this from In Progress to In Analysis in Avni Product Jun 21, 2024
@mahalakshme mahalakshme moved this from In Analysis to Ready in Avni Product Jun 21, 2024
@1t5j0y 1t5j0y moved this from Ready to In Progress in Avni Product Jun 21, 2024
@1t5j0y
Copy link
Contributor

1t5j0y commented Jun 21, 2024

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]
    }
};

@1t5j0y 1t5j0y moved this from In Progress to Code Review Ready in Avni Product Jun 21, 2024
@mahalakshme mahalakshme moved this from Code Review Ready to In Code Review in Avni Product Jun 21, 2024
@mahalakshme mahalakshme moved this from In Code Review to QA Ready in Avni Product Jun 25, 2024
@AchalaBelokar AchalaBelokar moved this from QA Ready to In QA in Avni Product Jun 26, 2024
@mahalakshme mahalakshme moved this from In QA to QA Ready in Avni Product Jun 27, 2024
@AchalaBelokar AchalaBelokar moved this from QA Ready to Done in Avni Product Jun 28, 2024
@AchalaBelokar AchalaBelokar moved this from Done to In QA in Avni Product Jun 28, 2024
@AchalaBelokar
Copy link

@1t5j0y
Copy link
Contributor

1t5j0y commented Jul 2, 2024

@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
Copy link

  • Tested with lahi intern attendance form but still message is not sending
  • and also check with boardcast feature that is alos not working.

@himeshr
Copy link
Contributor

himeshr commented Jul 29, 2024

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]
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants