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.
npm install openmrs.js
<script src="node_modules/openmrs.js/lib/openmrs.bundle.min.js"></script>
const OpenMRS = require('openmrs.js');
💡 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.
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.
See the OpenMRS CONTRIBUTING guidelines.
npm install
npm run build
npm test
Check out the npm scripts
for more stuff you can do.
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
.