avniproject / integration-service

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

Amrit Integration #36

Closed petmongrels closed 1 year ago

petmongrels commented 2 years ago

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

Integration Processes

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. Error Process: Process all error record in order (Subject, Child Entities).

Master Data

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.

Testing

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.