Skip to content

OpenMRS module to expose an API endpoint to access ERP data

Notifications You must be signed in to change notification settings

NepalEHR/openmrs-module-erp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenMRS module ERP

OpenMRS module to expose an API endpoint to access ERP data

Supported ERPs and models:

  • Odoo 10
    • Orders
    • Invoices

Required setup

Properties file:

Create the erp.properties file in the application directory (usually ~/.OpenMRS/) and add the ERP connection details into it, as per the example below:

erp.host=localhost
erp.port=8069
erp.user=admin
erp.password=password
erp.database=odoo

The contents may vary with the ERP you are connecting to. You can find the properties details in the specific implementation file of ErpConnection.java for your ERP here.

OpenMRS privilege:

Ensure the OpenMRS user has the Get ERP objects OpenMRS privilege assigned.

How to query the ERP objects?

Example with ERP Orders

Log in OpenMRS.

Fetch a single order by ID:

Method: GET

URL: /openmrs/ws/rest/v1/erp/order/{id}

  • {id}, a single order ID

URL Parameters:

Optional:

  • rep, the object representation, see below.

Success Response:

Code: 200 Response: A single record in the type of Map<String, Object>. The exact fields returned depend on the ERP and representation used.

{
  "invoice_ids": null,
  "pricelist_id": 1,
  "origin": null,
  ...
}

Fetch orders via filters:

Method: POST

URL: /openmrs/ws/rest/v1/erp/order

URL Parameters:

Optional:

  • rep, the object representation, see below.

Data Parameters:

Required:

  • filters: an array of maps with 3 keys: field, comparison, value For instance:
{
  "filters": [
    {
      "field": "amount_total",
      "comparison": "<",
      "value": "1000"
    },
    {
      "field": "create_date",
      "comparison": ">",
      "value": "2019-05-19"
    }
  ]
}

Success Response:

Code: 200

Response: A list of records in the type of List<Map<String, Object>>. The exact fields returned depend on the ERP and representation used.

[
  {
    "invoice_ids": null,
    "pricelist_id": 1,
    "origin": null
  },
  {
    "invoice_ids": null,
    "pricelist_id": 1,
    "origin": null
  },
  {
    "invoice_ids": null,
    "pricelist_id": 1,
    "origin": null
  }
]

More about the rep optional URL parameter:

URL Parameter:

Optional: rep, the object representation

One can specify how the returned object should be modeled/represented. There is 3 types of representations available:

  • default
  • full
  • custom

The default object representation is documented in the specific implementation of ErpOrderService.java for the ERP you are using.

The full representation simply returns all fields returned by the ERP.

The custom representation allows you to pass the fields you want to retrieve. Provide it with the following example syntax:

?rep=custom:amount_total,create_date,id

Get in touch

Find us on OpenMRS Talk: sign up, start a conversation and ping us with the mentions starting with @mks... in your message.


This module development has been sponsored by Hôpital Sacré Coeur in Haiti:

HSC logo

About

OpenMRS module to expose an API endpoint to access ERP data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%