Skip to content

🏥 JavaScript client library for the OpenMRS API

License

Notifications You must be signed in to change notification settings

psbrandt/openmrs.js

Repository files navigation

OpenMRS

openmrs.js

Build Status Code Quality Test Coverage npm npm

JavaScript client library for the OpenMRS API

This library provides a way for JavaScript developers to easily access the OpenMRS API in node or the browser.

Install

npm install openmrs.js

Setup

Browser
<script src="node_modules/openmrs.js/lib/openmrs.bundle.min.js"></script>
Node
const OpenMRS = require('openmrs.js');

Usage

💡 You will need version 2.14+ of the webservices.rest module installed.

const config = {
  user: 'admin',
  pass: 'Admin123',
  url: 'http://localhost:8080/openmrs',
};

const o = new OpenMRS(config);
const deferred = o.login();

deferred.then(() => {
  o.api.location.getAllLocations()
    .then(data => {
      console.log(data.obj);
    })
    .catch(error => {
      throw new Error('Houston, we have a problem', error);
    });
}).catch(error => {
  throw new Error('That didn\'t work', error);
});

You can also get help in the console:

> o.api.patient.help()
operations for the 'patient' tag
  * deletePatient: Delete or purge resource by uuid
  * getPatient: Fetch by uuid
  * updatePatient: Edit with given uuid, only modifying properties in request
  * getAllPatientIdentifiers: Fetch all non-retired identifier subresources
  * createPatientIdentifier: Create identifier subresource with properties in request
  * deletePatientIdentifier: Delete or purge resource by uuid
  * getPatientIdentifier: Fetch identifier subresources by uuid
  * updatePatientIdentifier: Edit identifier subresource with given uuid, only modifying properties in request
  * getAllPatients: Search for patient
  * createPatient: Create with properties in request

See the examples for further demonstrations.

API Documentation

The library code is automatically generated using swagger-js when a new instance is created, so the API available to you will depend on the version of OpenMRS you are running, and which modules you have installed.

You will always be able to see your API documentation in the OpenMRS web application by navigating to the advanced admin screen and clicking the API Documentation link.

Static API documentation for the OpenMRS Reference Application can be found here.

Browser Support

Browser Support

Development

See the OpenMRS CONTRIBUTING guidelines.

Build

npm install
npm run build

Test

npm test

Check out the npm scripts for more stuff you can do.

Community

OpenMRS Talk OpenMRS IRC OpenMRS Telegram OpenMRS Wiki

Support

Ask questions on OpenMRS Talk in the dev category using the javascript tag. Issues should be logged in the OMRSJS project on JIRA and the component should be set to openmrs.js.

License

MPL 2.0 w/ HD

About

🏥 JavaScript client library for the OpenMRS API

Resources

License

Stars

Watchers

Forks

Packages

No packages published