avniproject / integration-service

Service for integration Avni with other systems
GNU Affero General Public License v3.0
0 stars 2 forks source link

Sakhi Amrit Integration #18

Closed petmongrels closed 2 years ago

petmongrels commented 2 years ago

Some context

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.

  1. Spike using postman to check whether we can create beneficiary without all the fields.

  2. Create concept and concept answer mapping in production integration environment for Sakhi

  3. Create following mapping groups and mapping types in integration database and integration code

    • MG=(Beneficiary). MT=(CBAC, Household, Beneficiary, Birth)
  4. 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.

  5. Create external API in Avni, for individual relative feed, so that one can find the changes in relationship between individuals.

  6. On individual relationships update, update Amrit - unless one of the relatives have error.

  7. Process all errors for beneficiary and individual relationships feed.