Module order
- Bahmni
- Goonj
- Amrit
- Power
- Lahi
This project forked from avni-bahmni-integration/integration-service
Service for integration Avni with other systems
License: GNU Affero General Public License v3.0
Module order
Use case:
Once a student is sent a message over whatsapp from LAHI to express and confirm their interest in program(s), student will share their basic information such as Name, Gender, Age, School, etc. in response.
When the details are available in Gliffic, Avni needs to bring those details and store for student registration.
Some helpful scripts can be found here for defining the systemctl service in CentOS. We can use these or do it from scratch - depending on how we want to do it.
https://github.com/avniproject/avni-integrator-host
There are mechanisms to automate pulling of metadata for an organisation on integration-service. and pushing them to another organisation/implementation. This will be used to migrate changes from one organisation to another
To improve monitoring capability of Integration service:
All the dispatches should be visible in the data entry app, under their demand, in Avni for any user who has the privilege. Note that only the fields mapped will be visible. All the field and their coded answers mapping will be handled via a separate implementation story.
Post as new subject
The purpose of this task is to, prevent voided Goonj encounters from being upserted into Goonj SF. We need to filter out encounters (DispatchReceipt, Activity and Distribution) that were deleted in Salesforce and had the Avni "/delete" external API invoked for them. We should not sync them back to Goonj, due to change in their "isVoided" and "lastModifiedDateTime" fields.
Test this change only in Goonj Sandbox (GoonjUAT on prod).
Edit of DispatchReceipt right now can be handled cleanly only when the existing dispatchReceipt is deleted and a new one added.
When getting an edit for DispatchReceipt, then delete the entry from SalesForce and then add a new one.
Minor changes to attributes.
Change source from encounter to subject of type distribution
check if locationHeirarchy has to be corrected and forms should be made to work
Modify Sakhi to include Panchayat info:
addressLevel type should be added //done
data uploaded //done
Panchayat added before village //Done
externalID for all types //Pending
Add mapping for following:
literacyStatus //duplicate of educationName
stateID
districtID
blockID
districtBranchID
vanID
Create tasks for Amrit, And invoke Beneficiary and BeneficiaryScan as separate tasks..
Work on Amrit Error Records in AmritErrorJob
Process error records also as part of AmritMainJob
Make use of GetAmritID API call to get Amrit Beneficiary ID and use the same in update of Beneficiary and Create/update of all other entities in field "beneficiaryRegID"
If you face "Beneficiary registration not completed in AMRIT", during BeneficiaryScan, stop at that step.
Move to next entity sync. Before every entityType sync, perform getAmritId operation of beneficiary.
This will be posted as a subject, use AvniSubjectRepository instead of AvniEncounterRepository.
We also create Local Inventory items (subjects) if they do not exist and add them to the dispatch subject before creating it.
Minor changes to attributes
Change source from encounter to subject of type Activity.
Would be linked only to a Distribution, never to a Demand.
Currently we make use of code to map Avni entity fields to Distribution entity fields for sync from Avni to Salesforce, instead make use of MetaDataMappings to transpose AvniResponse to GoonjRequests.
Push all missed calls created in Exotel as tasks in Avni
Analysis
Limitation
0801928303 and 91801928303 are 2 different numbers
Handle Errors while Syncing between Salesforce and Avni:
In this iteration of the Goonj integration, we will be modifying the existing Goonj integration API to work with the new models.
There has been a change in the implementation of Goonj. We need to modify our existing integration to start working with the new implementation. Details of the new model is documented here
https://documenter.getpostman.com/view/21052731/2s8YRgpZHJ#eabe9124-1292-4dd3-8888-89f6549266fb
We have to push Beneficiary, Household, Birth, and CBAC data to Amrit.
The information on mandatory fields, conditional mandatory fields, and masters is in the following. For all APIs see the postman collection. Check the pre-request script and Tests also to understand the APIs better.
https://docs.google.com/document/d/17iYyxhYMJ3d4B5cZj7qRO_PH79YTM8mo/edit#
Beneficiary registration in Amrit is functionally async involving two APIs - sync and getAmritIdForAvniId. Sync API returns success. In order to get the Amrit ID for the beneficiary "Get AMRIT ID for Avni ID" API is called. If the beneficiary has been created then it would provide Amrit id. For unprocessed and unknown it would not provide any Amrit ID. For failures, it would provide an error.
You can read about integration architecture here first, as the approach discussed uses these concepts - https://avni.readme.io/docs/integration-architecture
Subject: Before saving check whether the subject already exists using 'Get AMRIT ID for Avni ID'.
If present or not present - then make the save call. If the subject is in error then log the error and proceed to the next record.
Four states to handle - not saved, not attempted, saved, error.
Subject Save Error Check: This is to check for subjects for which create has been called and to make sure any errors in subject created are captured. Check for all subjects' "Get AMRIT ID for Avni ID". If there is an error then add it error records and process the next entity. If the entity is not found then end the integration process. If found then move to the next entity.
Subject Re-Save: Not sure whether we need this process. This process is required if a Subject remains in the not found status - this process can try to resave the subject. This will be required only if the async process on the Amrit end is faulty and is missing some records.
Child Entities: Call "Get AMRIT ID for Avni ID" for the subject ID. If the Subject is not found then end integration processing. If Subject ID is in error then log this Child Entity in the integration error_log in integration DB and move to the next record.
Error Process: Process all error record in order (Subject, Child Entities).
There are certain master data used by Amrit in beneficiary registration (not for other entities). For these we have to send the id of master data corresponding to our our concept. Mapping for the master data can be done via the UI. All these masters except location related are available via the API "Get Master Data".
Location master data will be provided by Amrit team which will be imported in our Avni and to mapping metadata in integration database. Avni external api uses location title for identifying a location hence the mapping can be created by dump we receive from Amrit team.
There are three modes in which we need to do testing - developer, full run, and QA. But we have a single environment, hence the it may become difficult to verify the results clearly. We can assign locations for each type of testing. e.g. District 1-2 for dev, District 3-4 for qa etc.
Usually in integration testing we can do a full run on large volume of existing data to identify any issues, but in this case - we don't have much data. So this will remain a risk when we go live.
Details of access to UAT environment is present in KeeWeb. Using this login we can verify the successful and correct saving of avni records. Use advanced search to find beneficiaries.
Currently we only create or update Avi source Goonj Enitities, DispatchReceipt, Distribution and Activity in Salesforce.
We would need to include "isVoided" field as part of Post Request for those EntityTypes or invoke a separate Deletion API, as per Salesforce design.
Acceptance Criteria:
.* We should be able to delete Goonj Enitities DispatchReceipt, Distribution and Activity in Salesforce if they have been voided in Avni.
.* Handle Deletion errors
Handle boundary conditions at the end of the feed while syncing from SF <=> Avni
Handle boundary conditions at the end of the feed while syncing from Avni <=> SF
Beneficiary post to Amrit takes data from multiple Avni entities - subject (Individual, Household), program enrolment (pregnancy, child), and encounter (CBAC) in Avni. The integration should be triggered on Individual, Pregnancy Enrolment, Child Enrolment, and CBAC encounter - in that order. This is based on assumption that Amrit can take partial data. If not, we would have to relook at this (see the spike below to validate this)
Amrit expects all the relationships of a beneficiary to be posted via a single API. In Avni, the relationship is an independent entity and can be added between two subjects at any time. Hence when posting a beneficiary to Amrit we will be posting only beneficiaries at that point in time. When a new relationship is added both the entities in Amrit should get updated.
One way to solve this is to call Amrit and update all affected beneficiaries on every relationship change.
If post of a beneficiary fails then an error record should be created with beneficiary id, enrolment id or encounter id - for each type of event respectively. Each event processing should check whether the parent id is already present in the error record. If it is already present in then it should also log itself to the error record.
Create external API in Avni, for individual relative feed, so that one can find the changes in relationship between individuals.
On individual relationships update, update Amrit - unless one of the relatives have error.
Process all errors for beneficiary and individual relationships feed.
New subject of type Local Inventory created/updated.
Create Subject Type and Conepts / AnswerConcepts and Form for Local Inventory. make use of Distribution concepts for this purpose.
Config clean up and deploy to
Before every entityType sync, perform getAmritId operation of beneficiary.
Config clean up in code base
Setup config in prod
Deploy to prod
strore config in keeweb
Acceptance criteria
When there are tasks for a specific number that is not in a terminal state from the same number, then it should not create a new task.
PS: Lower in priority from a delivery order perspective
Dispatch receipt is created in Avni as an Encounter
###Objective
By the end of this epic, Avni should be able to send HSM templated Whatsapp messages to Glific. These messages can be configured to run at the end of filling up a form, at scheduled times or based on a time that is derived from a form field.
There will be a new module - AvniMessagingService. This service will take in requests to send a message to a beneficiary at a specific point in time. It will also sync HSM messages from Glific, and provide mechanisms to store rules that map parameters in an HSM message to variables available in Avni.
Sample API for AvniMessagingService
API in AvniService
Data model available here - https://dbdiagram.io/d/6228ad1661d06e6eadcf53d1"
Required mainly for production. In uat, we have configured only one village.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.