How to implement interoperability between 2 DHIS2 instance

Hi All,

I’m newbie on DHIS2. I implemented an instance that work for my organisation and I need to Interoperate with MOH instance to retrieve data each month for some health facilities.

I need guidance on how to set up interoperability by using web API and how to create a cronjob that will fetch data from MOH instance to my instance each month.

Could you please help me to find ressources (course, tutorials, step by step code, etc.) and advises on how to implement?

Thank you all for your help.

Hi Vunda

The nature of a Web API is its openness to be used by any software.

As a start, I would start in trying to understand how such an API
works, which is based on “HTTP REST” principles.

REST in layman's terms: REST basics (IBM developers):

Specification for DHIS2:
As an example, the programming language Python can be used, which is
installable on any system and is on Ubuntu by default. DHIS2
supports the transportation format JSON. There’s a new library on
github (, but have not tried it
yet) or you can write your own.
So a basic procedure would be:
myscript.py

  1. load a configuration of both APIs (username, url, passwords)
  2. make a GET request to a specific endpoint of MoH API
  3. validate, transform,… the received data
  4. make a POST request to another specific endpoint of your other
    instance’s API
    and then install a cronjob which calls this script with “* * * * *
    python myscript.py”
    Further extensions could be logging to a file and a mail
    notification if something goes wrong.
    I hope this can help a bit.
    Best regards
    David
···

http://www.looah.com/source/view/2284
https://www.ibm.com/developerworks/library/ws-restful/index.html
https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html

https://github.com/dhis2/dhis2-python

On 03.04.2016 08:34, vunda limbe wrote:

Hi All,

          I'm newbie on DHIS2. I implemented an instance that work

for my organisation and I need to Interoperate with MOH
instance to retrieve data each month for some health
facilities.

        I need guidance on how to set up interoperability by using

web API and how to create a cronjob that will fetch data
from MOH instance to my instance each month.

      Could you please help me to find ressources (course,

tutorials, step by step code, etc.) and advises on how to
implement?

Thank you all for your help.

_______________________________________________
Mailing list: Post to : Unsubscribe : More help :

https://launchpad.net/~dhis2-usersdhis2-users@lists.launchpad.nethttps://launchpad.net/~dhis2-usershttps://help.launchpad.net/ListHelp

Hi David and Everybody,

I begun to learn what you told me, but I’m stucked at the begining. Do you have an example of script that I can based on to build mine that work?

Thanks for your support.

···

On Tue, Apr 5, 2016 at 9:18 AM, David Huser david.huser@swisstph.org wrote:

Hi Vunda

The nature of a Web API is its openness to be used by any software. As a start, I would start in trying to understand how such an API works, which is based on "HTTP REST" principles.

REST in layman's terms: [http://www.looah.com/source/view/2284](http://www.looah.com/source/view/2284)

REST basics (IBM developers): [https://www.ibm.com/developerworks/library/ws-restful/index.html](https://www.ibm.com/developerworks/library/ws-restful/index.html)

Specification for DHIS2: [https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html](https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html)



As an example, the programming language Python can be used, which is installable on any system and is on Ubuntu by default. DHIS2 supports the transportation format JSON. There's a new library on github ([https://github.com/dhis2/dhis2-python](https://github.com/dhis2/dhis2-python)    , but have not tried it yet) or you can write your own.

So a basic procedure would be:



myscript.py

1. load a configuration of both APIs (username, url, passwords)

2. make a GET request to a specific endpoint of MoH API

3. validate, transform,... the received data

4. make a POST request to another specific endpoint of your other instance's API



and then install a cronjob which calls this script with "* * * * * python myscript.py"



Further extensions could be logging to a file and a mail notification if something goes wrong.



I hope this can help a bit.



Best regards

David

On 03.04.2016 08:34, vunda limbe wrote:

Hi All,

          I'm newbie on DHIS2. I implemented an instance that work for my organisation and I need to Interoperate with MOH instance to retrieve data each month for some health facilities.
        I need guidance on how to set up interoperability by using web API and how to create a cronjob that will fetch data from MOH instance to my instance each month.
      Could you please help me to find ressources (course, tutorials, step by step code, etc.) and advises on how to implement?

Thank you all for your help.

_______________________________________________ Mailing list: [https://launchpad.net/~dhis2-users](https://launchpad.net/~dhis2-users)
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : [https://launchpad.net/~dhis2-users](https://launchpad.net/~dhis2-users)
More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)

It seems that david change is mail adress.

···

On Mon, Feb 27, 2017 at 9:22 PM, vunda limbe vundalon@gmail.com wrote:

Hi David and Everybody,

I begun to learn what you told me, but I’m stucked at the begining. Do you have an example of script that I can based on to build mine that work?

Thanks for your support.

On Tue, Apr 5, 2016 at 9:18 AM, David Huser david.huser@swisstph.org wrote:

Hi Vunda

The nature of a Web API is its openness to be used by any software. As a start, I would start in trying to understand how such an API works, which is based on "HTTP REST" principles.

REST in layman's terms: [http://www.looah.com/source/view/2284](http://www.looah.com/source/view/2284)

REST basics (IBM developers): [https://www.ibm.com/developerworks/library/ws-restful/index.html](https://www.ibm.com/developerworks/library/ws-restful/index.html)

Specification for DHIS2: [https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html](https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html)



As an example, the programming language Python can be used, which is installable on any system and is on Ubuntu by default. DHIS2 supports the transportation format JSON. There's a new library on github ([https://github.com/dhis2/dhis2-python](https://github.com/dhis2/dhis2-python)    , but have not tried it yet) or you can write your own.

So a basic procedure would be:



myscript.py

1. load a configuration of both APIs (username, url, passwords)

2. make a GET request to a specific endpoint of MoH API

3. validate, transform,... the received data

4. make a POST request to another specific endpoint of your other instance's API



and then install a cronjob which calls this script with "* * * * * python myscript.py"



Further extensions could be logging to a file and a mail notification if something goes wrong.



I hope this can help a bit.



Best regards

David

On 03.04.2016 08:34, vunda limbe wrote:

Hi All,

          I'm newbie on DHIS2. I implemented an instance that work for my organisation and I need to Interoperate with MOH instance to retrieve data each month for some health facilities.
        I need guidance on how to set up interoperability by using web API and how to create a cronjob that will fetch data from MOH instance to my instance each month.
      Could you please help me to find ressources (course, tutorials, step by step code, etc.) and advises on how to implement?

Thank you all for your help.

_______________________________________________ Mailing list: [https://launchpad.net/~dhis2-users](https://launchpad.net/~dhis2-users)
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : [https://launchpad.net/~dhis2-users](https://launchpad.net/~dhis2-users)
More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)

Hi Vunda

Can you share what you got so far and what you would like to do eventually?

Maybe data or metadata synchronization would be an option?

https://docs.dhis2.org/master/en/user/html/dhis2_user_manual_en_full.html#dataAdmin_dataSync

https://docs.dhis2.org/master/en/user/html/dhis2_user_manual_en_full.html#metadata_sync

I attached a very basic Python script that just adds “myChange” to all names of dataElements that begin with “ANC” (on Demo server).

To run it, you need to install the library requests (it’s a very good library for making API calls but you can use built-in methods as well) with pip:

  1. Install pip: https://pip.pypa.io/en/stable/installing/

  2. In a terminal: pip install requests

  3. Change directories to the folder where you downloaded de-renamer.py with cd /path/to/folder

  4. Inspect the code and what it does

  5. In the same terminal: python de-renamer.py

Good luck! Let us know how it went.

David

de-renamer.py (815 Bytes)

···

On Mon, Feb 27, 2017 at 9:23 PM, vunda limbe vundalon@gmail.com wrote:

It seems that david change is mail adress.

On Mon, Feb 27, 2017 at 9:22 PM, vunda limbe vundalon@gmail.com wrote:

Hi David and Everybody,

I begun to learn what you told me, but I’m stucked at the begining. Do you have an example of script that I can based on to build mine that work?

Thanks for your support.

On Tue, Apr 5, 2016 at 9:18 AM, David Huser david.huser@swisstph.org wrote:

Hi Vunda

The nature of a Web API is its openness to be used by any software. As a start, I would start in trying to understand how such an API works, which is based on "HTTP REST" principles.

REST in layman's terms: [http://www.looah.com/source/view/2284](http://www.looah.com/source/view/2284)

REST basics (IBM developers): [https://www.ibm.com/developerworks/library/ws-restful/index.html](https://www.ibm.com/developerworks/library/ws-restful/index.html)

Specification for DHIS2: [https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html](https://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual_full.html)



As an example, the programming language Python can be used, which is installable on any system and is on Ubuntu by default. DHIS2 supports the transportation format JSON. There's a new library on github ([https://github.com/dhis2/dhis2-python](https://github.com/dhis2/dhis2-python)    , but have not tried it yet) or you can write your own.

So a basic procedure would be:



myscript.py

1. load a configuration of both APIs (username, url, passwords)

2. make a GET request to a specific endpoint of MoH API

3. validate, transform,... the received data

4. make a POST request to another specific endpoint of your other instance's API



and then install a cronjob which calls this script with "* * * * * python myscript.py"



Further extensions could be logging to a file and a mail notification if something goes wrong.



I hope this can help a bit.



Best regards

David

On 03.04.2016 08:34, vunda limbe wrote:

Hi All,

          I'm newbie on DHIS2. I implemented an instance that work for my organisation and I need to Interoperate with MOH instance to retrieve data each month for some health facilities.
        I need guidance on how to set up interoperability by using web API and how to create a cronjob that will fetch data from MOH instance to my instance each month.
      Could you please help me to find ressources (course, tutorials, step by step code, etc.) and advises on how to implement?

Thank you all for your help.

_______________________________________________ Mailing list: [https://launchpad.net/~dhis2-users](https://launchpad.net/~dhis2-users)
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : [https://launchpad.net/~dhis2-users](https://launchpad.net/~dhis2-users)
More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)

David Huser
DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K Street, Suite 406, Washington D.C. 20007