Atom Feed Based Synchronization in Bahmni

Bahmni uses an Atom Feed based framework created by ThoughtWorks ICT4H team for data synchronization between OpenMRS, OpenELIS and OpenERP (in fact also with Reference Data app). For more information on this read: 

Atom Feed Console Viewer

In version v0.86 of Bahmni an Atom Feed viewer has been released with Bahmni which can allow you to see Failed events in Bahmni. It can be accessed at url: http://<ip>/atomfeed-console. For instance here is the online demo url for atomfeed console: The Github project for Atom Feed console is:

The tables used in Atom Feed are:

Table NameUsed in ModeDescription

This tables holds the list of events which are to be published by Atom Feed for others to consume. The category column is used to indicate the event types (like patient, encounter, etc).

Note: For the same patient updates there might be multiple rows. So to see unique rows: "select distinct object from event_records where category = 'patient';"

markersCONSUMERThis table holds marker entries to indicate the records which have ALREADY been processed. 
event_records_offset_markerCONSUMERThis table holds cached records for faster event process by the CONSUMER.
failed_eventsCONSUMERThis table holds the list of events which failed and could not be consumed. They are retried later by a different event handler.

Note: The PUBLISH mode is when the system is publishing its events on an Atom Feed. The CONSUME mode is when the system is reading events from another system and writing/updating its own data based on consumed events. OpenMRS, OpenELIS, Odoo – all act as Publisher and Consumer depending on the scenario. For instance, when a Patient is created in Bahmni(OpenMRS), then Bahmni is PUBLISHER and ELIS/Odoo are CONSUMERS. When a Lab result is entered in ELIS, then ELIS is PUBLISHER and Bahmni/OpenMRS is CONSUMER of results. Therefore, these 4 tables will exist in each sub-system that acts as Atom Feed publisher & consumer. Example URL for OpenMRS Encounter Feed: view-source: (select View-Source in browser)

Different Components like OpenMRS, OpenERP and OpenELIS are kept in Sync using the "Atom Feed Based Synchronization".  The following is the depiction:

Lets take an example of Drug creation in bahmni.  The following are the sequence of events:

  1. Administrators create Drugs using OpenMRS or using the "CSV Upload" feature on Bahmni's Admin module
  2. Once the drug is created, an event is published (more technical details in the github links above)
  3. The "OpenERP atom feed service" contains batch jobs that are scheduled to consume these atom feed events.
  4. The job then creates an event in OpenERP.