# @openfn/language-openmrs

> OpenFn adaptor for OpenMRS

Latest version **5.5.1** (published 2026-10-23) · LGPLv3 license · 0 weekly downloads

## Install

```sh
npm install @openfn/language-openmrs
pnpm add @openfn/language-openmrs
yarn add @openfn/language-openmrs
bun add @openfn/language-openmrs
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.5.1 |
| Published | 2026-10-23 |
| First published | 2021-06-18 |
| Weekly downloads | 0 |
| License | LGPLv3 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 138.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 26 |
| Author | Open Function Group |
| Maintainers | elias-ba, stuartc-openfn, taylordowns2000, mtuchi, jclark-openfn |

## Links

- npm: https://www.npmjs.com/package/@openfn/language-openmrs
- Repository: https://github.com/OpenFn/adaptors
- Homepage: https://docs.openfn.org
- npm.io page: https://npm.io/package/@openfn/language-openmrs

## Dependencies (1)

- [@openfn/language-common](https://npm.io/package/@openfn/language-common.md) 3.3.5

## Recent versions

- 5.5.1 (latest) — 2026-10-23
- 5.5.0 — 2026-09-03
- 5.4.2 — 2026-06-30
- 5.4.1 — 2026-05-27
- 5.4.0 — 2026-05-21
- 5.3.12 — 2026-05-20
- 5.3.11 — 2026-04-16
- 5.3.10 — 2026-04-07
- 5.3.9 — 2026-03-30
- 5.3.8 — 2026-02-24
- 5.3.7 — 2026-01-30
- 5.3.6 — 2025-11-28
- 5.3.5 — 2025-11-12
- 5.3.4 — 2025-10-29
- 5.3.3 — 2025-10-16
- … 57 more at https://npm.io/package/@openfn/language-openmrs/versions

## README

# language-openmrs <img src='./assets/square.png' width="30" height="30"/>

Language Pack for building expressions and operations for working with the
[OpenMRS Rest API](https://rest.openmrs.org/?javascript#openmrs-rest-api)

[OpenMRS Data Model Explorer](http://burkeware.com/openmrs-data-model/openmrs-data-model-1.11.html#)

## Documentation

### Configuration

View all the required and optional properties for `state.configuration` in the
official
[configuration-schema](https://docs.openfn.org/adaptors/packages/openmrs-configuration-schema/)
definition.

### Get a patient by some criteria

```js
// getPatient({ uuid: '516af9aa-0402-4e11-ad79-e394fdec0c91' });
// getPatient({ uuid: dataValue('patientId')(state) });
getPatient({
  uuid: state => state.data[0].uuid,
});
```

#### Example of searching for patients based on their `EMR Id`

```js
getPatients(
  {
    identifier: state => state.data.emrId,
    v: 'full',
  },
  {
    exactlyOne: true,
  }
);
```

### Create an Encounter

```js
createEncounter({
  encounterDatetime: dataValue('visit_date'), //dynamically fill with source app data
  patient: dataValue('uuid'),
  encounterType: dataValue('visit_type'),
  location: dataValue('location.uuid'),
  encounterProviders: [
    {
      provider: dataValue('provider_name'),
      encounterRole: '240b26f9-dd88-4172-823d-4a8bfeb7841f', //hardcoded value
    },
  ],
});
```

### Make a request to any OpenMRS endpoint

```js
get('/ws/rest/v1/patient', { q: 'mohammed' }, state => {
  console.log(JSON.stringify(state, null, 2));
  return state;
});
```

## Create new patient

```js
createPatient(
  fields(
    field('gender', 'M'),
    field('names', function (state) {
      return [
        {
          patient_id: dataValue('form.patientId')(state),
          creator: dataValue('form.user')(state),
        },
      ];
    })
  )
);
```

## Development

Clone the [adaptors monorepo](https://github.com/OpenFn/adaptors). Follow the
`Getting Started` guide inside to get set up.

Run tests using `pnpm run test` or `pnpm run test:watch`

Build the project using `pnpm build`.

To just build the docs run `pnpm build docs`

---
_Source: https://npm.io/package/@openfn/language-openmrs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
