Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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: 

Tip
titleAtom 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:

Introduction to Atom Feed Based Synchronization


Tip
titleVideo Overview - AtomFeed Sync

YouTube Video giving an overview of Atom Feed sync mechanism of Bahmni: ATOM Feed Integration in Bahmni (Online session)

Bahmni uses ATOM Feed synchronization (event notification over REST APIs) to allow services to pull for changes occurring in Bahmni. The Bahmni EMR (OpenMRS) publishes various event feeds, like Patient, Encounter, Lab, Drug feeds, and the other systems subscribe to these event feeds, to be notified of changes. Based on the "notification", the downstream consuming systems make a REST API call to OpenMRS, to pull relevant data. Typically a sync service is written for each consumer, that listens to these events, constructs the relevant data packets, and then pushes to downstream system (like ELIS, ERP, etc).

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

Image Added

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 (in the Drug Feed)
  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 (or Odoo).

Various Feeds Published in Bahmni


Feed NameURLDescription
1OpenMRS Patient Feed

Recent Events: https://demo.mybahmni.org/openmrs/ws/atomfeed/patient/recent

Page1 Events: https://demo.mybahmni.org/openmrs/ws/atomfeed/patient/1


Click on "View Source" to see the actual XML feed
2OpenMRS Encounter Feedhttps://demo.mybahmni.org/openmrs/ws/atomfeed/encounter/recentEncounters between Provider and Patients (along with data logged in those encounters)
3OpenMRS Lab Eventshttps://demo.mybahmni.org/openmrs/ws/atomfeed/lab/recent
4OpenMRS Drug Eventshttps://demo.mybahmni.org/openmrs/ws/atomfeed
-console. The Github project for Atom Feed console is: https

 See this sample configuration file for various feeds (in OpenERP Sync Service): erp-atomfeed.properties


Reference Code in Bahmni for Various Atom Feed Sync Services


Data FlowEntities being sentCode RepoCode Link
1OpenMRS (EMR) → OpenELIS (Lab)Patient, Tests/Panels, Lab OrdersOpenELISLabFeedEventWorker.java
2OpenELIS (Lab) → OpenMRS (EMR)Test Resultsbahmni-coreOpenElisAccessionEventWorker.java
3OpenMRS (EMR) → Odoo (ERP)

Patient, Drugs, Tests/Panels, Drug Orders, Lab Orders, 

Service Orders

openerp-atomfeed-service
4OpenMRS (EMR) → DCM4chee (Radiology)Patient, Radiology Orderspacs-integrationPACSIntegrationService.java (Atomfeed + HL7)
5Sample Code Repo to write your own integration
bahmni-feed-integration-examplePatientFeedJob.java


Underlying ATOM Feed Libraries

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 the underlying atomfeed implementation please refer to: 

-console

Underlying Database Tables for Atom Feed Synchronization Book-Keeping

The tables used behind the scene in Atom Feed are:

Table NameUsed in ModeDescription
event_records
Status
colourGreen
titlePUBLISHER

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';"

markers
Status
colourBlue
titleCONSUMER
This table holds marker entries to indicate the records which have ALREADY been processed. 
event_records_offset_marker
Status
colourBlue
titleCONSUMER
This table holds cached records for faster event process by the CONSUMER.
failed_events
Status
colourBlue
titleCONSUMER
This 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 Patient Feed: view-source:https://demo.mybahmni.org/openmrs/ws/atomfeed/patient/recent (Select View-Source in browser) and https://demo.mybahmni.org/openmrs/ws/atomfeed/patient/1 for first page of events.
  • Example URL for OpenMRS Encounter Feed: view-source:https://demo.mybahmni.org/openmrs/ws/atomfeed/encounter/recent (select View-Source in browser)
  • Example URL for OpenMRS Lab Events Feed: view-source

    AtomFeed Console Viewer

    Tip
    titleAtom 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: https://demo.mybahmni.org

    /openmrs/ws

    /atomfeed

    /lab/recent (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:

    Image Removed

    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.

    Reference Code in Bahmni for Various Atom Feed Sync Services

    Data FlowEntities being sentCode RepoCode Link1OpenMRS (EMR) → OpenELIS (Lab)Patient, Tests/Panels, Lab OrdersOpenELISLabFeedEventWorker.java2OpenELIS (Lab) → OpenMRS (EMR)Test Resultsbahmni-coreOpenElisAccessionEventWorker.java3OpenMRS (EMR) → Odoo (ERP)

    Patient, Drugs, Tests/Panels, Drug Orders, Lab Orders, 

    Service Orders

    openerp-atomfeed-service4OpenMRS (EMR) → DCM4chee (Radiology)Patient, Radiology Orderspacs-integrationPACSIntegrationService.java (Atomfeed + HL7)

    -console. The Github project for Atom Feed console is: https://github.com/ict4h/atomfeed-console