NAV
shell java javascript

OpenMRS REST API

This documentation serves as a reference to the bespoke REST API for OpenMRS.

Purpose

Getting Started

Current version

Schema

Getting Started with examples

1. Instructions for all the examples

Java Code Stubs



import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        try {

            // the examples go here

        } catch (IOException exception) {

            // handle exception here
        }
    }
}

2. Getting Started with Java Code samples

3. Getting Started with JavaScript Code samples

Terms

Resources

Querying a resource(Role)

GET /role?v=default&limit=1

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/role?limit=1&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/role?limit=1&v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

For Instance Querying a Resource

Subresources

Accessing a Subresource under parent URL

POST /openmrs/ws/rest/v1/person/:target_person_uuid/name
{
  "givenName": "John",
  "familyName": "Smith"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n  \"givenName\": \"John\",\r\n  \"familyName\": \"Smith\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/070f0120-0283-4858-885d-a20d967729cf/name")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=A1644AD703C71E603C4E87B79291D075")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=A1644AD703C71E603C4E87B79291D075");

var raw = JSON.stringify({"givenName":"John","familyName":"Smith"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/070f0120-0283-4858-885d-a20d967729cf/name", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Resources with subtypes

Usage Examples of Resources with SubTypes

Usage Examples of Resources(Order) with SubTypes

POST /openmrs/ws/rest/v1/order
{
  "type":"testorder",
  "action": "new",
  "urgency": "ROUTINE",
  "dateActivated": "2018-10-16 12:08:43",
  "careSetting": "INPATIENT" ,
  "encounter": "69f83020-caf2-4c9e-bca7-89b8e62b52e1",
  "patient": "96be32d2-9367-4d1d-a285-79a5e5db12b8",
  "concept": "5087AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
  "orderer": "f9badd80-ab76-11e2-9e96-0800200c9a66"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n  \"type\":\"testorder\",\r\n  \"action\": \"new\",\r\n  \"urgency\": \"ROUTINE\",\r\n  \"dateActivated\": \"2018-10-16 12:08:43\",\r\n  \"careSetting\": \"INPATIENT\" ,\r\n  \"encounter\": \"69f83020-caf2-4c9e-bca7-89b8e62b52e1\",\r\n  \"patient\": \"96be32d2-9367-4d1d-a285-79a5e5db12b8\",\r\n  \"concept\": \"5087AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\",\r\n  \"orderer\": \"f9badd80-ab76-11e2-9e96-0800200c9a66\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/order")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=A1644AD703C71E603C4E87B79291D075")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=A1644AD703C71E603C4E87B79291D075");

var raw = JSON.stringify({"type":"testorder","action":"new","urgency":"ROUTINE","dateActivated":"2018-10-16 12:08:43","careSetting":"INPATIENT","encounter":"69f83020-caf2-4c9e-bca7-89b8e62b52e1","patient":"96be32d2-9367-4d1d-a285-79a5e5db12b8","concept":"5087AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","orderer":"f9badd80-ab76-11e2-9e96-0800200c9a66"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/order", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Querying Resources with subtypes

Querying Resources with subtypes (drug order)

GET  /openmrs/ws/rest/v1/order?type=drugorder&v=full

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/order?type=drugorder&v=full")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A1644AD703C71E603C4E87B79291D075")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A1644AD703C71E603C4E87B79291D075");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/order?type=drugorder&v=full", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Querying Resources with subtypes (drug order)

Authentication

Retrieve session token

Retrieve session token

GET /openmrs/ws/rest/v1/session 
  -H 'Authorization: Basic Auth <base64 encoded username:password'
    OkHttpClient client = new OkHttpClient().newBuilder()
            .build();
    Request request = new Request.Builder()
            .url("/openmrs/ws/rest/v1/session")
            .method("GET", null)
            .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
            .build();
    Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=2D158E83ACFB788998C7DB495F07C1B9");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/session", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response

{
    "sessionId": "2D158E83ACFB788998C7DB495F07C1B9",
    "authenticated": true,
    "user": {
        "uuid": "45ce6c2e-dd5a-11e6-9d9c-0242ac150002",
        "display": "admin",
        "username": "admin",
        "systemId": "admin",
        "userProperties": {
            "loginAttempts": "0",
            "emrapi.lastViewedPatientIds": "508,509,511,512,513,514,515,516,517,510,518,519,520,521,522,523,524,507,44,525"
        },
        "person": {
            "uuid": "24252571-dd5a-11e6-9d9c-0242ac150002"
        },
        "privileges": [],
        "roles": [
            {
                "uuid": "8d94f852-c2cc-11de-8d13-0010c6dffd0f",
                "name": "System Developer"
            },
            {
                "uuid": "8d94f280-c2cc-11de-8d13-0010c6dffd0f",
                "name": "Provider"
            }
        ]
    },
    "locale": "en_GB",
    "allowedLocales": [
        "en",
        "en_GB",
        "es",
        "fr",
        "it",
        "pt"
    ],
    "sessionLocation": null
}

Logout User/End session

Logout User/End session

DELETE /openmrs/ws/rest/v1/session -H 'Accept: application/json'
-H 'Authorization: Basic Auth' (required to identify the user)
    OkHttpClient client = new OkHttpClient().newBuilder().build();
    Request request = new Request.Builder()
        .url("/openmrs/ws/rest/v1/session")
        .method("DELETE", null)
        .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
        .build();
    Response response = client.newCall(request).execute();      

var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=2D158E83ACFB788998C7DB495F07C1B9");

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/session", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Changing Password

Password change By Admin

POST /openmrs/ws/rest/v1/password/:target_user_uuid 
{
  "newPassword" : "newPassword"
}

    OkHttpClient client = new OkHttpClient().newBuilder()
            .build();
    MediaType mediaType = MediaType.parse("application/json");

    //password should contain atleast 1 integer
    RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"newPassword\" : \"password1\"\r\n}");
    Request request = new Request.Builder()
            .url("/openmrs/ws/rest/v1/password/45ce6c2e-dd5a-11e6-9d9c-0242ac150002")
            .method("POST", body)
            .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
            .addHeader("Content-Type", "application/json")
            .build();
    Response response = client.newCall(request).execute();
}


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=2D158E83ACFB788998C7DB495F07C1B9");

var raw = JSON.stringify({"newPassword":"newPassword1"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/password/45ce6c2e-dd5a-11e6-9d9c-0242ac150002", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Since version 2.17 of the webservices.rest module:

Password change By Users

POST /openmrs/ws/rest/v1/password 
{
  "oldPassword" : "oldPassword",
  "newPassword" : "newPassword"
}
    OkHttpClient client = new OkHttpClient().newBuilder().build();
    MediaType mediaType = MediaType.parse("application/json");

    RequestBody body = RequestBody.create(mediaType, "{\r\n  \"oldPassword\" : \"Admin123\",\r\n  \"newPassword\" : \"newPassword1\"\r\n}");
    Request request = new Request.Builder()
      .url("/openmrs/ws/rest/v1/password")
      .method("POST", body)
      .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
      .addHeader("Content-Type", "application/json")
      .build();
    Response response = client.newCall(request).execute();

var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=2D158E83ACFB788998C7DB495F07C1B9");

var raw = JSON.stringify({"oldPassword":"Admin123","newPassword":"newPassword1"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/password \n", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Getting all location without authentication

Getting all location without authentication

GET /openmrs/ws/rest/v1/location?tag=Login+Location' 

    OkHttpClient client = new OkHttpClient().newBuilder()
            .build();
    Request request = new Request.Builder()
            .url("/openmrs/ws/rest/v1/location?tag=Login+Location")
            .method("GET", null)
            .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
            .build();
    Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=2D158E83ACFB788998C7DB495F07C1B9");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/location?tag=Login+Location'\n", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

User

User Overview

A User in OpenMRS is an account that a person may use to log into the system.

The real-life person is represented by a Person record in OpenMRS, and a person may have more than one user account. If you want a patient to be able to view her record in OpenMRS, then you need to create a user account and link it to the patient's person record.

Available operations for User

  1. List users
  2. Create a user
  3. Update a user
  4. Delete a user

List all non-retired users.

Get all non-retired Users

GET user?q=admin&v=default


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/user?q=admin
&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/user?q=admin&v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response

{
    "results": [
        {
            "uuid": "45ce6c2e-dd5a-11e6-9d9c-0242ac150002",
            "display": "admin",
            "username": "admin",
            "systemId": "admin",
            "userProperties": {
                "loginAttempts": "0",
                "emrapi.lastViewedPatientIds": "19,513,323,522,523,529"
            },
            "person": {
                "uuid": "24252571-dd5a-11e6-9d9c-0242ac150002",
                "display": "Super User",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/24252571-dd5a-11e6-9d9c-0242ac150002"
                    }
                ]
            },
            "privileges": [],
            "roles": [
                {
                    "uuid": "8d94f852-c2cc-11de-8d13-0010c6dffd0f",
                    "display": "System Developer",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/role/8d94f852-c2cc-11de-8d13-0010c6dffd0f"
                        }
                    ]
                },
                {
                    "uuid": "8d94f280-c2cc-11de-8d13-0010c6dffd0f",
                    "display": "Provider",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/role/8d94f280-c2cc-11de-8d13-0010c6dffd0f"
                        }
                    ]
                }
            ],
            "retired": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002?v=full"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

Quickly filter users with given query parameters. Add parameter includeAll=true to also retrieve disabled users. Returns a 404 Not Found status if the user does not exist. If not logged in to perform this action, a 401 Unauthorized status is returned.

Query Parameters

Parameter Type Description
q Search Query Filter users by username or system ID
includeAll Boolean If true, returns also disabled users

Get user by UUID.

Get User by UUID

GET /user/:target_user_uuid

1. Here the target UUID used is of the admin user.  

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();


1. Here the target UUID used is of the admin user.  

var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a user

Create a new User using person object

{
    "username": "demoUser",
    "password": "Password123",
    "person": {
        "names": [
            {
                "givenName": "Demo",
                "familyName": "User"
            }
        ],
        "gender": "M",
        "birthdate": "1997-09-02",
        "addresses": [
            {
                "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
                "cityVillage": "Bengaluru",
                "country": "India",
                "postalCode": "560037"
            }
        ]
    },
    "roles": [
        {
            "name": "Configures Forms",
            "description": "Manages forms and attaches them to the UI"
        }
    ],
   "systemId": "systemId"
}

Create a new User using person UUID

POST /user
{
    "username": "demoUser",
    "password": "Password123",
    "person": "90f7f0b4-06a8-4a97-9678-e7a977f4b518",
    "systemId": "systemId",
    "roles": [
        "774b2af3-6437-4e5a-a310-547554c7c65c"
    ]
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"username\": \"demoUser\",\r\n    \"password\": \"Password123\",\r\n    \"person\": {\r\n        \"names\": [\r\n            {\r\n                \"givenName\": \"Demo\",\r\n                \"familyName\": \"User\"\r\n            }\r\n        ],\r\n        \"gender\": \"M\",\r\n        \"birthdate\": \"1997-09-02\",\r\n        \"addresses\": [\r\n            {\r\n                \"address1\": \"30, Vivekananda Layout, Munnekolal,Marathahalli\",\r\n                \"cityVillage\": \"Bengaluru\",\r\n                \"country\": \"India\",\r\n                \"postalCode\": \"560037\"\r\n            }\r\n        ]\r\n    },\r\n    \"roles\": [\r\n        {\r\n            \"name\": \"Configures Forms\",\r\n            \"description\": \"Manages forms and attaches them to the UI\"\r\n        }\r\n    ],\r\n   \"systemId\": \"systemId\"\r\n}\r\n\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/user")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();

var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var raw = JSON.stringify({"username":"demoUser","password":"Password123","person":{"names":[{"givenName":"Demo","familyName":"User"}],"gender":"M","birthdate":"1997-09-02","addresses":[{"address1":"30, Vivekananda Layout, Munnekolal,Marathahalli","cityVillage":"Bengaluru","country":"India","postalCode":"560037"}]},"roles":[{"name":"Configures Forms","description":"Manages forms and attaches them to the UI"}],"systemId":"systemId"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/user", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
name String Name of the user
description String Description of the user
username String username of the user
password String password of the user
person String person resource associated with the user
systemId String a unique identifier assigned to each user
roles Array[] : role a list of roles attributed to the user
userProperties JSON Object A set of key value pairs. Used to store user specific data
secretQuestion String A secret question chosen by the user

Update a user

Update a user using its UUID

POST /user/:target_user_uuid
{
    "username": "demoUserUpdated"
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"username\": \"demoUserUpdated\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/user/0f25e7bc-0d76-4889-8fbf-70ad7d7802a9")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var raw = JSON.stringify({"username":"demoUserUpdated"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/user/0f25e7bc-0d76-4889-8fbf-70ad7d7802a9", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
name String Name of the user
description String Description of the user
username String username of the user
password String password of the user
person String person resource associated with the user
systemId String a unique identifier assigned to each user
roles Array[] : role a list of roles attributed to the user
userProperties JSON Object A set of key value pairs. Used to store user specific data
secretQuestion String A secret question chosen by the user

Delete a user

Delete a user using its UUID

DELETE /user/:target_user_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/user/b953d87d-7e67-47b9-ad1e-fa8b7cdaea4d?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=154692F02BBBC664825F3C4C224A474B")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/user/b953d87d-7e67-47b9-ad1e-fa8b7cdaea4d?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Query Parameters

Parameter Type Description
purge Boolean The resource will be voided unless purge = ‘true’

Role

Role Overview

A Role represents a group of privileges in the system. Roles may inherit privileges from other roles, and users may have one or more roles.

Available operations for Role.

  1. List roles
  2. Create a role
  3. Update a role
  4. Delete a role

List roles

List roles

GET /role?v=default&limit=1

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://demo.openmrs.org/openmrs/ws/rest/v1/role?limit=1&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/role?limit=1&v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "774b2af3-6437-4e5a-a310-547554c7c65c",
            "display": "Anonymous",
            "name": "Anonymous",
            "description": "Privileges for non-authenticated users.",
            "retired": false,
            "privileges": [],
            "inheritedRoles": [],
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/role/774b2af3-6437-4e5a-a310-547554c7c65c"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/role/774b2af3-6437-4e5a-a310-547554c7c65c?v=full"
                }
            ],
            "resourceVersion": "1.8"
        }
    ],
    "links": [
        {
            "rel": "next",
            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/role?limit=1&v=default&startIndex=1"
        }
    ]
}

Get a role by UUID.

Get a role by UUID

GET /role/:target_role_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://demo.openmrs.org/openmrs/ws/rest/v1/role/774b2af3-6437-4e5a-a310-547554c7c65c")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/role/774b2af3-6437-4e5a-a310-547554c7c65c", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

*Retrieve a role by its UUID. Returns a 404 Not Found status if the role does not exist. If the user is not logged in to perform this action, a 401 Unauthorized status is returned.

Create a role

Create a role

POST /role
{
    "name": "Clinician",
    "description": "A provider assisting the Lead Surgeon.",
    "privileges": [
        {
            "name": "Delete Patients",
            "description": "Able to delete patients"
        }
    ],
    "inheritedRoles": [
        "774b2af3-6437-4e5a-a310-547554c7c65c"
    ]
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"Clinician\",\r\n    \"description\": \"A provider assisting the Lead Surgeon.\",\r\n    \"privileges\": [\r\n        {\r\n            \"name\": \"Delete Patients\",\r\n            \"description\": \"Able to delete patients\"\r\n        }\r\n    ],\r\n    \"inheritedRoles\": [\r\n        \"774b2af3-6437-4e5a-a310-547554c7c65c\"\r\n    ]\r\n}");
Request request = new Request.Builder()
  .url("https://demo.openmrs.org/openmrs/ws/rest/v1/role")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA");

var raw = JSON.stringify({"name":"Clinician","description":"A provider assisting the Lead Surgeon.","privileges":[{"name":"Delete Patients","description":"Able to delete patients"}],"inheritedRoles":["774b2af3-6437-4e5a-a310-547554c7c65c"]});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/role", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
name String Name of the role (Required)
description String Description of the role (Required)
privileges Array[] : privileges An array of the privilege resource
inheritedRoles Array[] : inheritedRoles An array of the inheritedRoles type or UUIDs

Update a role

POST /role/:target_role_uuid
{
  "description": "Manages forms and attaches them to the UI"
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n  \"description\": \"Manages forms and attaches them to the UI\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("https://demo.openmrs.org/openmrs/ws/rest/v1/role/86f043da-1019-4caf-8db6-d5a472334f58")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA");

var raw = JSON.stringify({"description":"Manages forms and attaches them to the UI"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/role/86f043da-1019-4caf-8db6-d5a472334f58", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))


Attributes

Parameter Type Description
name String Name of the role (Required)
description String Description of the role (Required)
privileges Array[] : privileges An array of the privilege resource
inheritedRoles Array[] : inheritedRoles An array of the inheritedRoles type or UUIDs

Delete a role

Delete a role

DELETE /role/:target_role_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://demo.openmrs.org/openmrs/ws/rest/v1/role/86f043da-1019-4caf-8db6-d5a472334f58?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/role/86f043da-1019-4caf-8db6-d5a472334f58?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Privilege

Overview

A Privilege is an authorization to perform a particular action in the system. The list of available privileges are defined by the core system and by add-on modules (for example, Delete Patients and Manage Encounter Types), but you need to configure which roles have which privileges while you are configuring your system.

Available operations.

  1. List privilege
  2. Create a privilege
  3. Update a privilege
  4. Delete a privilege

List privilege

List privilege

    GET /privilege?v=full&limit=1

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/privilege?v=full&limit=1")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/privilege?v=full&limit=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
         {
            "uuid": "24635eec-dd5a-11e6-9d9c-0242ac150002",
            "display": "Add Concept Proposals",
            "name": "Add Concept Proposals",
            "description": "Able to add concept proposals to the system",
            "retired": false,
            "auditInfo": {
                "creator": null,
                "dateCreated": null,
                "changedBy": null,
                "dateChanged": null
            },
            "links": [
                {
                    "rel": "self",
                    "uri":"http://demo.openmrs.org/openmrs/ws/rest/v1/privilege/24635eec-dd5a-11e6-9d9c-0242ac150002"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

Get privilege by UUID

Get privilege by UUID

    GET /privilege/:target_privilege_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/privilege/fd40ed09-b499-405a-8b98-8154a6465e1a")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/privilege/fd40ed09-b499-405a-8b98-8154a6465e1a", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a privilege

Create a privilege

POST /privilege
{
    "name": "Delete Patients",
    "description": "A privilege or permission to delete patients"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"Delete Patients\",\r\n    \"description\": \"A privilege or permission to delete patients\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/privilege")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var raw = JSON.stringify({"name":"Delete Patients","description":"A privilege or permission to delete patients"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/privilege", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Update a privilege

Update a privilege

POST /privilege/:target_privilege_uuid
{
    "description": "A user who can delete all the encounter types"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"description\": \"A user who can delete all the encounter types\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/privilege/246364a0-dd5a-11e6-9d9c-0242ac150002")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var raw = JSON.stringify({"description":"A user who can delete all the encounter types"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/privilege/246364a0-dd5a-11e6-9d9c-0242ac150002", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete a privilege

Delete a privilege

   DELETE /privilege/:target_privilege_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/privilege/24636447-dd5a-11e6-9d9c-0242ac150002?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/privilege/24636447-dd5a-11e6-9d9c-0242ac150002?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Person

Person Overview

Every individual who is referred to in a patient record in OpenMRS is stored in the system as a Person. These include Patients, any patient relative or caretaker, Providers, and Users.

All Persons have these characteristics.

Subresource types

Names

Addresses

Person Attributes

Available Operations for Person type

  1. Search Persons
  2. Create Persons
  3. Update Persons
  4. Delete Persons
  5. List person name
  6. Create person name
  7. Update person name
  8. Delete person name
  9. List person addresses
  10. Create person address
  11. Update person address
  12. Delete person address
  13. List person attributes
  14. Create person attribute
  15. Update person attribute
  16. Delete person attribute

Search Persons

Search Persons

GET /person?q=all&limit=1&v=default

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person?q=all&limit=1&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person?q=all&limit=1&v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "e739808f-f166-42ae-aaf3-8b3e8fa13fda",
            "display": "Christopher Allen",
            "gender": "M",
            "age": 62,
            "birthdate": "1958-05-17T00:00:00.000+0000",
            "birthdateEstimated": false,
            "dead": false,
            "deathDate": null,
            "causeOfDeath": null,
            "preferredName": {
                "uuid": "8fbf3a24-43e9-4e6c-a56c-798e85760493",
                "display": "Christopher Allen",
                "links": [
                    {
                        "rel": "self",
                        "uri": "/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda/name/8fbf3a24-43e9-4e6c-a56c-798e85760493",
                        "resourceAlias": "name"
                    }
                ]
            },
            "preferredAddress": {
                "uuid": "a0897bec-f008-4f45-b531-2544aaebd71d",
                "display": "Address12463",
                "links": [
                    {
                        "rel": "self",
                        "uri": "/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda/address/a0897bec-f008-4f45-b531-2544aaebd71d",
                        "resourceAlias": "address"
                    }
                ]
            },
            "attributes": [],
            "voided": false,
            "birthtime": null,
            "deathdateEstimated": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda",
                    "resourceAlias": "person"
                },
                {
                    "rel": "full",
                    "uri": "/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda?v=full",
                    "resourceAlias": "person"
                }
            ],
            "resourceVersion": "1.11"
        }
    ],
    "links": [
        {
            "rel": "next",
            "uri": "/openmrs/ws/rest/v1/person?q=all&limit=1&v=default&startIndex=1",
            "resourceAlias": null
        }
    ]
}

Parameters

Parameter Type Description
q string search by name or for listing all the persons q=all

List person by UUID

List person by UUID

GET /person/:target_person_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a person

Create a person

POST /person
{
    "names": [
        {
        "givenName": "Mohit",
        "familyName": "Kumar"
        }
    ],
    "gender": "M",
    "birthdate": "1997-09-02",
    "addresses": [
        {
        "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
        "cityVillage": "Bengaluru",
        "country": "India",
        "postalCode": "560037"
        }
    ]
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"names\": [\r\n        {\r\n        \"givenName\": \"Mohit\",\r\n        \"familyName\": \"Kumar\"\r\n        }\r\n    ],\r\n    \"gender\": \"M\",\r\n    \"birthdate\": \"1997-09-02\",\r\n    \"addresses\": [\r\n        {\r\n        \"address1\": \"30, Vivekananda Layout, Munnekolal,Marathahalli\",\r\n        \"cityVillage\": \"Bengaluru\",\r\n        \"country\": \"India\",\r\n        \"postalCode\": \"560037\"\r\n        }\r\n    ]\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"names":[{"givenName":"Mohit","familyName":"Kumar"}],"gender":"M","birthdate":"1997-09-02","addresses":[{"address1":"30, Vivekananda Layout, Munnekolal,Marathahalli","cityVillage":"Bengaluru","country":"India","postalCode":"560037"}]});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
names Array[] : names List of names
gender String The patient's gender ("M" for male, "F" for female, or "U" for unknown)
age Integer The estimated age in years. Used when birthdate is unknown.
birthDate String Date of birth of a person
birthDateEstimated Boolean True if the birthdate is estimated; false if birthdate is accurate.
birthTime String The time of birth of the person
dead Boolean True if the patient is dead.
deathDate String Date of death of the person
causeOfDeath Concept UUID Reason for the death of the person
deathdateEstimated Boolean true if deathDate is estimate; false if deathDate is accurate
addresses Array[] : addresses The address details aggregated in an array
attributes Array[] : attributes The attribute details aggregated in an array

Update a person

Update a person

POST /person/:target_person_uuid
{
    "gender": "M",
    "birthdate": "1997-01-13",
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"gender\": \"M\",\r\n    \"birthdate\": \"1997-01-13\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"gender":"M","birthdate":"1997-01-13"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete a person

Delete a person

DELETE /person/:target_person_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/e739808f-f166-42ae-aaf3-8b3e8fa13fda?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

List person name subresource

List person name subresource

GET /person/:target_person_uuid/name

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "display": "John Taylor",
            "uuid": "4b68f067-6f4d-451a-bd80-342fc21ea486",
            "givenName": "John",
            "middleName": null,
            "familyName": "Taylor",
            "familyName2": null,
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4b68f067-6f4d-451a-bd80-342fc21ea486",
                    "resourceAlias": "name"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4b68f067-6f4d-451a-bd80-342fc21ea486?v=full",
                    "resourceAlias": "name"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

List person name subresource by UUID

List person name subresource by UUID

GET /person/:target_person_uuid/name/:target_name_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4b68f067-6f4d-451a-bd80-342fc21ea486")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4b68f067-6f4d-451a-bd80-342fc21ea486", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create person name subresource

Create person name subresource

POST person/:target_person_uuid/name
{ 
    "givenName": "Mohit",
    "familyName": "Kumar",
    "preferred": true,
    "prefix": "Mr."
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"givenName\": \"Mohit\",\r\n    \"familyName\": \"Kumar\",\r\n    \"preferred\": true,\r\n    \"prefix\": \"Mr.\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"givenName":"Mohit","familyName":"Kumar","preferred":true,"prefix":"Mr."});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Update person name subresource

Update person name subresource

POST person/:target_person_uuid/name/:target_name_uuid
{ 
    "givenName": "Mohit",
    "familyName": "Verma",
    "preferred": true,
    "prefix": "Dr."
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"givenName\": \"Mohit\",\r\n    \"familyName\": \"Verma\",\r\n    \"preferred\": true,\r\n    \"prefix\": \"Dr.\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4e5c5c75-323e-43f4-afad-c5970209d0f9")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"givenName":"Mohit","familyName":"Verma","preferred":true,"prefix":"Dr."});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4e5c5c75-323e-43f4-afad-c5970209d0f9", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete person name subresource

Delete person name subresource

DELETE /person/:target_person_uuid/person/:target_name_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4e5c5c75-323e-43f4-afad-c5970209d0f9?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/name/4e5c5c75-323e-43f4-afad-c5970209d0f9?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));


List person address subresource

List person address subresource

GET /person/:target_person_uuid/address

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "display": "Address15501",
            "uuid": "e350d53f-0252-4259-8d87-d97a2d58166e",
            "preferred": true,
            "address1": "Address15501",
            "address2": null,
            "cityVillage": "City5501",
            "stateProvince": "State5501",
            "country": "Country5501",
            "postalCode": "55501",
            "countyDistrict": null,
            "startDate": null,
            "endDate": null,
            "latitude": null,
            "longitude": null,
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/e350d53f-0252-4259-8d87-d97a2d58166e",
                    "resourceAlias": "address"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/e350d53f-0252-4259-8d87-d97a2d58166e?v=full",
                    "resourceAlias": "address"
                }
            ],
            "resourceVersion": "2.0"
        }
    ]
}

List person address subresource by UUID

List person address subresource by UUID

GET /person/:target_person_uuid/address/:target_address_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/e350d53f-0252-4259-8d87-d97a2d58166e")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/e350d53f-0252-4259-8d87-d97a2d58166e", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create person address subresource

Create person address subresource

POST person/:target_person_uuid/address
{ 
    "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
    "cityVillage": "Bengaluru",
    "stateProvince": "Karnataka",
    "postalCode": "560037",
    "latitude": "28.65033",
    "longitude": "77.304255"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"address1\": \"30, Vivekananda Layout, Munnekolal,Marathahalli\",\r\n    \"cityVillage\": \"Bengaluru\",\r\n    \"stateProvince\": \"Karnataka\",\r\n    \"postalCode\": \"560037\",\r\n    \"latitude\": \"28.65033\",\r\n    \"longitude\": \"77.304255\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"address1":"30, Vivekananda Layout, Munnekolal,Marathahalli","cityVillage":"Bengaluru","stateProvince":"Karnataka","postalCode":"560037","latitude":"28.65033","longitude":"77.304255"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address", requestOptions)


Update person address subresource

Update person address subresource

POST person/:target_person_uuid/address/:target_address_uuid
{ 
    "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
    "cityVillage": "Bengaluru",
    "stateProvince": "Karnataka",
    "postalCode": "560037",
    "latitude": "28.65033",
    "longitude": "77.304255"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"address1\": \"30, Vivekananda Layout, Munnekolal,Marathahalli\",\r\n    \"cityVillage\": \"Bengaluru\",\r\n    \"stateProvince\": \"Karnataka\",\r\n    \"postalCode\": \"560037\",\r\n    \"latitude\": \"28.65033\",\r\n    \"longitude\": \"77.304255\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/62fc41dd-e120-40c5-8a66-b651b0a5fecc")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"address1":"30, Vivekananda Layout, Munnekolal,Marathahalli","cityVillage":"Bengaluru","stateProvince":"Karnataka","postalCode":"560037","latitude":"28.65033","longitude":"77.304255"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/62fc41dd-e120-40c5-8a66-b651b0a5fecc", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
preferred Boolean true if this is the person's preferred address. If a person has multiple addresses, only one can be preferred.
address1 String address of the person
address2 String second address of the person
cityVillage String city/village of the person
stateProvince String name of the state of the person
country String country of the person
postalCode String pin code of the person
countyDistrict String county district of the person
address3 String third address of the person
address4 String fourth address of the person
address5 String fifth address of the person
address6 String sixth address of the person
startDate String date when the person began living at this address
endDate String date when the person stopped living at this address
latitude String latitude of the address
longitude String longitude of the address

Delete a person address subresource

Delete a person address subresource

DELETE /person/:target_person_uuid/person/:target_address_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/62fc41dd-e120-40c5-8a66-b651b0a5fecc")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/address/62fc41dd-e120-40c5-8a66-b651b0a5fecc", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

List person attribute subresource

List person attribute subresource

GET /person/:target_person_uuid/attribute

Success Response


{
    "results": [
        {
            "display": "Birthplace = Birthplace",
            "uuid": "2c7a8991-2435-47df-b7a4-83ca5c341dcd",
            "value": "Birthplace",
            "attributeType": {
                "uuid": "8d8718c2-c2cc-11de-8d13-0010c6dffd0f",
                "display": "Birthplace",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/personattributetype/8d8718c2-c2cc-11de-8d13-0010c6dffd0f",
                        "resourceAlias": "personattributetype"
                    }
                ]
            },
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd",
                    "resourceAlias": "attribute"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd?v=full",
                    "resourceAlias": "attribute"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

List person attribute subresource by UUID

List person attribute subresource by UUID

GET /person/:target_person_uuid/attribute/:target_attribute_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create person attribute subresource

Create person attribute subresource

POST person/:target_person_uuid/attribute
{ 
    "attributeType": "8d8718c2-c2cc-11de-8d13-0010c6dffd0f",
    "value": "Birthplace",
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"attributeType\": \"8d8718c2-c2cc-11de-8d13-0010c6dffd0f\",\r\n    \"value\": \"Birthplace\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"attributeType":"8d8718c2-c2cc-11de-8d13-0010c6dffd0f","value":"Birthplace"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute", requestOptions)
  .then(response => response.text())


Attributes

Parameter Type Description
attributeType UUID UUID of the attributeType (Required)
value String value associated with the attribute (Required)

Update person attribute subresource

Update person attribute subresource

POST person/:target_person_uuid/attribute/:target_attribute_uuid
{ 
    "attributeType": "8d8718c2-c2cc-11de-8d13-0010c6dffd0f",
    "value": "Birthplace"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"attributeType\": \"8d8718c2-c2cc-11de-8d13-0010c6dffd0f\",\r\n    \"value\": \"Birthplace\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var raw = JSON.stringify({"attributeType":"8d8718c2-c2cc-11de-8d13-0010c6dffd0f","value":"Birthplace"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
attributeType UUID UUID of the attributeType (Required)
value String value associated with the attribute (Required)

Delete person attribute subresource

Delete person attribute subresource

DELETE /person/:target_person_uuid/person/:target_attribute_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/person/90f7f0b4-06a8-4a97-9678-e7a977f4b518/attribute/2c7a8991-2435-47df-b7a4-83ca5c341dcd?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));


Person Attribute Type

Person Attribute Type Overview

Available operations.

  1. List person attribute types
  2. Create a person attribute type
  3. Update a person attribute type
  4. Delete a person attribute type

List all non-retired person attribute types.

List all non-retired person attribute types

GET /personattributetype?q=race&v=default

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/personattributetype?q=race&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/personattributetype?q=race&v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "8d871386-c2cc-11de-8d13-0010c6dffd0f",
            "display": "Race",
            "name": "Race",
            "description": "Group of persons related by common descent or heredity",
            "format": "java.lang.String",
            "foreignKey": 0,
            "sortWeight": 6.0,
            "searchable": false,
            "editPrivilege": null,
            "retired": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/personattributetype/8d871386-c2cc-11de-8d13-0010c6dffd0f"
                },
                {
                    "rel": "full",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/personattributetype/8d871386-c2cc-11de-8d13-0010c6dffd0f?v=full"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

Get person attribute type by UUID.

Get person attribute type by UUID

GET /personattributetype/:target_person_attribute_type_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/personattributetype/8d871386-c2cc-11de-8d13-0010c6dffd0f")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/personattributetype/8d871386-c2cc-11de-8d13-0010c6dffd0f", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a person attribute type

Create a person attribute type

POST /personattributetype
{
    "name": "Edit Civil Status",
    "description": "Able to manage the civil status of persons",
    "format": "org.openmrs.Concept",
    "foreignKey": 1054,
    "searchable": false,
    "editPrivilege": "24635eec-dd5a-11e6-9d9c-0242ac150002"
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"Edit Civil Status\",\r\n    \"description\": \"Able to manage the civil status of persons\",\r\n    \"format\": \"org.openmrs.Concept\",\r\n    \"foreignKey\": 1054,\r\n    \"searchable\": false,\r\n    \"editPrivilege\": \"24635eec-dd5a-11e6-9d9c-0242ac150002\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/personattributetype")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=F8F836D691AB75C7845C6B658D0018E2")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=F8F836D691AB75C7845C6B658D0018E2");

var raw = JSON.stringify({"name":"Edit Civil Status","description":"Able to manage the civil status of persons","format":"org.openmrs.Concept","foreignKey":1054,"searchable":false,"editPrivilege":"24635eec-dd5a-11e6-9d9c-0242ac150002"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/personattributetype", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Update a person attribute type

Update a person attribute type

POST /personattributetype
{
    "name": "Manage Civil Status"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"Manage Civil Status\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/personattributetype/aa7569c5-f81f-4e63-ab1f-810103f297ba")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=F8F836D691AB75C7845C6B658D0018E2")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=F8F836D691AB75C7845C6B658D0018E2");

var raw = JSON.stringify({"name":"Manage Civil Status"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/personattributetype/aa7569c5-f81f-4e63-ab1f-810103f297ba", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))


Delete a person attribute type

Delete a person attribute type

DELETE /personattributetype/:target_person_attribute_type_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/personattributetype/8d8718c2-c2cc-11de-8d13-0010c6dffd0f?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83")
  .build();
Response response = client.newCall(request).execute();


var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=1A5193DBE052C38DC303BAD947A05A83");

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/personattributetype/8d8718c2-c2cc-11de-8d13-0010c6dffd0f?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Patients

Patients Overview

Subresource types of Patient

PatientIdentifier (Identifier)

Allergy

1. Allergen

An allergen refers to a substance capable of triggering a response that starts in the immune system and results in an allergic reaction, for eg in drugs Aspirin, Codeine.., in food beef, eggs.. and others like dust and pollen.

2. Severity

Refers to the severity of the allergy e.g. mild , moderate and severe (uuid:=1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)

3. Reactions

Reactions refers to the effects of the allergy on anybody for e.g. headache(uuid:=139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) or even unknown(uuid:=1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)

Available operations for Patients

  1. List Patients
  2. Create a patient record
  3. Update a patient record
  4. Delete a patient record
  5. List patientIdentifier sub resource
  6. Create patientIdentifier sub resource with properties
  7. Update patientIdentifier sub resource
  8. Delete patientIdentifier sub resource
  9. List allergy sub resource
  10. Create allergy sub resource with properties
  11. Update allergy sub resource
  12. Delete allergy sub resource

Search patients

Search patients

GET /patient?q=Sarah&v=default&limit=1

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient?q=Sarah&v=default&limit=1")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient?q=Sarah&v=default&limit=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "b52ec6f9-0e26-424c-a4a1-c64f9d571eb3",
            "display": "1003EY - Sarah Lewis",
            "identifiers": [
                {
                    "uuid": "5c09b5b6-de14-4a28-bb0c-761a82cbdc1b",
                    "display": "OpenMRS ID = 1003EY",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/identifier/5c09b5b6-de14-4a28-bb0c-761a82cbdc1b"
                        }
                    ]
                }
            ],
            "person": {
                "uuid": "b52ec6f9-0e26-424c-a4a1-c64f9d571eb3",
                "display": "Sarah Lewis",
                "gender": "F",
                "age": 83,
                "birthdate": "1936-12-04T00:00:00.000+0000",
                "birthdateEstimated": false,
                "dead": false,
                "deathDate": null,
                "causeOfDeath": null,
                "preferredName": {
                    "uuid": "b3918971-c099-4cbe-a323-4b31e4edd493",
                    "display": "Sarah Lewis",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/name/b3918971-c099-4cbe-a323-4b31e4edd493"
                        }
                    ]
                },
                "preferredAddress": {
                    "uuid": "1955ab01-20ac-4dc4-8c11-74578b05e004",
                    "display": "Address14081",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/address/1955ab01-20ac-4dc4-8c11-74578b05e004"
                        }
                    ]
                },
                "attributes": [],
                "voided": false,
                "birthtime": null,
                "deathdateEstimated": false,
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3"
                    },
                    {
                        "rel": "full",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/person/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3?v=full"
                    }
                ],
                "resourceVersion": "1.11"
            },
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3?v=full"
                }
            ],
            "resourceVersion": "1.8"
        }
    ],
    "links": [
        {
            "rel": "next",
            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient?q=Sarah&v=default&limit=1&startIndex=1"
        }
    ]
}

Query Parameters

Parameter Type Description
q Search Query Display Name of patient.
attributesToFindDuplicatesBy String Patient attributes to find duplicates by. Example of attributes: gender,identifier,birthdate,givenName,middleName,familyName. If you want to include voided patients, add includeVoided attribute.

List patient by UUID.

List patient by UUID

GET /patient/:target_patient_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a patient

Create a new patient.

POST /patient
{
   "identifiers":[
      {
         "identifier":"103VWY7",
         "identifierType":"71075074-f02e-4270-89a3-f2dcda436f70",
         "location":"9356400c-a5a2-4532-8f2b-2361b3446eb8",
         "preferred":true
      }
   ],
   "person":{
      "gender":"M",
      "age":47,
      "birthdate":"1970-01-01T00:00:00.000+0100",
      "birthdateEstimated":false,
      "dead":false,
      "deathDate":null,
      "causeOfDeath":null,
      "names":[
         {
            "givenName":"Thomas",
            "familyName":"Smith"
         }
      ],
      "addresses": [
        {
        "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
        "cityVillage": "Bengaluru",
        "country": "India",
        "postalCode": "560037"
        }
      ]
    }
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"identifiers\":[ \r\n  {\"identifier\":\"103VWY7\", \r\n \"identifierType\":\"71075074-f02e-4270-89a3-f2dcda436f70\",\r\n \"location\":\"9356400c-a5a2-4532-8f2b-2361b3446eb8\", \r\n \"preferred\":true}\r\n ], \r\n \"person\":{\r\n \"gender\":\"M\", \r\n \"age\":47,\r\n \"birthdate\":\"1970-01-01T00:00:00.000+0100\",\r\n \"birthdateEstimated\":false,\r\n \"dead\":false,\r\n \"deathDate\":null,\r\n \"causeOfDeath\":null,\r\n \"names\":[\r\n {\r\n  \"givenName\":\"Thomas\",\r\n \"familyName\":\"Smith\" \r\n }\r\n ],\r\n \"addresses\":[\r\n {\r\n \"address1\":\"30,VivekanandaLayout,Munnekolal,Marathahalli\",\r\n \"cityVillage\":\"Bengaluru\",\r\n \"country\":\"India\",\r\n \"postalCode\":\"560037\"\r\n }\r\n]\r\n}\r\n }");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var raw = JSON.stringify({"identifiers":[{"identifier":"103VWY7","identifierType":"71075074-f02e-4270-89a3-f2dcda436f70","location":"9356400c-a5a2-4532-8f2b-2361b3446eb8","preferred":true}],"person":{"gender":"M","age":47,"birthdate":"1970-01-01T00:00:00.000+0100","birthdateEstimated":false,"dead":false,"deathDate":null,"causeOfDeath":null,"names":[{"givenName":"Thomas","familyName":"Smith"}] , "addresses": [{"address1": "30, Vivekananda Layout, Munnekolal,Marathahalli","cityVillage": "Bengaluru","country": "India","postalCode": "560037"}]}});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a patient from an existing person.

Create a patient

POST /patient
{
    "person": "b52ec6f9-0e26-424c-a4a1-c64f9d571eb3",
    "identifiers": [
        {
            "identifier": "1003EY",
            "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
            "location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
            "preferred": false
        }
    ]
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"person\": \"b52ec6f9-0e26-424c-a4a1-c64f9d571eb3\",\r\n    \"identifiers\": [\r\n        {\r\n            \"identifier\": \"1003EY\",\r\n            \"identifierType\": \"05a29f94-c0ed-11e2-94be-8c13b969e334\",\r\n            \"location\": \"8d6c993e-c2cc-11de-8d13-0010c6dffd0f\",\r\n            \"preferred\": false\r\n        }\r\n    ]\r\n}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var raw = JSON.stringify({"person":"b52ec6f9-0e26-424c-a4a1-c64f9d571eb3","identifiers":[{"identifier":"1003EY","identifierType":"05a29f94-c0ed-11e2-94be-8c13b969e334","location":"8d6c993e-c2cc-11de-8d13-0010c6dffd0f","preferred":false}]});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Properties

Parameter Type Description
person Person_UUID Person resource UUID (Reqired)
identifiers Array[]: patientIdentifiers List of patientIdentifiers (Required)

Update a patient

Update a patient

  1. For instance we just want to add one more identifier

POST /patient/:target_patient_uuid/identifier
{
    "identifier": "1003EY",
    "identifierType": "a5d38e09-efcb-4d91-a526-50ce1ba5011a",
    "location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
    "preferred": false
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"identifier\": \"1003EY\",\r\n    \"identifierType\": \"a5d38e09-efcb-4d91-a526-50ce1ba5011a\",\r\n    \"location\": \"8d6c993e-c2cc-11de-8d13-0010c6dffd0f\",\r\n    \"preferred\": false\r\n}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/identifier")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var raw = JSON.stringify({"identifier":"1003EY","identifierType":"a5d38e09-efcb-4d91-a526-50ce1ba5011a","location":"8d6c993e-c2cc-11de-8d13-0010c6dffd0f","preferred":false});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/identifier", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

### Properties

Parameter Type Description
person Person_UUID Person resource UUID
identifiers Array[]: patientIdentifiers List of patientIdentifiers

Delete a patient

Delete a patient

DELETE /patient/:target_patient_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

List patientIdentifier sub resources

List patientIdentifier sub resources

GET /patient/:target_patient_uuid/identifier

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "display": "OpenMRS ID = 1001W2",
            "uuid": "a122f3ce-4039-4f8c-9d6f-3faf64c7cb69",
            "identifier": "1001W2",
            "identifierType": {
                "uuid": "05a29f94-c0ed-11e2-94be-8c13b969e334",
                "display": "OpenMRS ID",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334",
                        "resourceAlias": "patientidentifiertype"
                    }
                ]
            },
            "location": {
                "uuid": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
                "display": "Unknown Location",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/location/8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
                        "resourceAlias": "location"
                    }
                ]
            },
            "preferred": true,
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/a122f3ce-4039-4f8c-9d6f-3faf64c7cb69",
                    "resourceAlias": "identifier"
                },
                {
                    "rel": "full",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/a122f3ce-4039-4f8c-9d6f-3faf64c7cb69?v=full",
                    "resourceAlias": "identifier"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

List patientIdentifier sub resource by it's UUID and parent patient UUID.

List patientIdentifier sub resource by it's UUID

GET /patient/:target_patient_uuid/identifier/:target_identifier_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/a122f3ce-4039-4f8c-9d6f-3faf64c7cb69")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/a122f3ce-4039-4f8c-9d6f-3faf64c7cb69", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a patientIdentifier sub resource with properties

Create a patientIdentifier sub resource

POST patient/:target_patient_uuid/identifier
{ 
    "identifier" : "111:CLINIC1",
    "identifierType" : "a5d38e09-efcb-4d91-a526-50ce1ba5011a",
    "location" : "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
    "preferred" : true
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"identifier\" : \"111:CLINIC1\",\r\n    \"identifierType\" : \"a5d38e09-efcb-4d91-a526-50ce1ba5011a\",\r\n    \"location\" : \"8d6c993e-c2cc-11de-8d13-0010c6dffd0f\",\r\n    \"preferred\" : true\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var raw = JSON.stringify({"identifier":"111:CLINIC1","identifierType":"a5d38e09-efcb-4d91-a526-50ce1ba5011a","location":"8d6c993e-c2cc-11de-8d13-0010c6dffd0f","preferred":true});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Properties

Parameter type Description
identifier String value of the identifier (Required)
identifierType Identifier_Type_UUID Create identifier from this Identifier_type (Required)
location Location UUID Get patients for this location
preferred boolean preferred/not preferred identifier

Update patientIdentifier sub resource with properties

Update patientIdentifier sub resource

POST patient/:target_patient_uuid/identifier/:target_identifier_uuid
{ 
    "identifier" : "111:CLINIC2",
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n    \"identifier\" : \"111:CLINIC2\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/beb6be1f-07a3-484c-a4ff-92fcb566ddde")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var raw = JSON.stringify({"identifier":"111:CLINIC2"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/e739808f-f166-42ae-aaf3-8b3e8fa13fda/identifier/beb6be1f-07a3-484c-a4ff-92fcb566ddde", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Properties

Parameter Type Description
identifier String updated value of the identifier
identifierType Identifier_Type_UUID Create identifier from this Identifier_type
location Location UUID updated location
preferred boolean updated status of preferred/not preferred identifier

Delete patientIdentifier sub resource with properties

Delete patientIdentifier sub resource

DELETE /patient/:target_patient_uuid/identifier/:target_identifier_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/c7ea5ea9-bec7-4ad0-a803-0ef2dee8fca5/identifier/e5ce3659-9118-4912-8c2f-6d470c2c7940?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/c7ea5ea9-bec7-4ad0-a803-0ef2dee8fca5/identifier/e5ce3659-9118-4912-8c2f-6d470c2c7940?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

List allergy subresources

List allergy subresources

GET /patient/:target_patient_uuid/allergy/

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  body: null,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87", requestOptions)
  .then(response => response.text())


Success Response


{
    "results": [
        {
            "display": "ACE inhibitors",
            "uuid": "2d440f27-7a87-4a14-bd21-efb5e99c58dc",
            "allergen": {
                "allergenType": "DRUG",
                "codedAllergen": {
                    "uuid": "162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                    "display": "ACE inhibitors",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/concept/162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                        }
                    ]
                },
                "nonCodedAllergen": ""
            },
            "severity": {
                "uuid": "1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                "display": "Severe",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/concept/1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                    }
                ]
            },
            "comment": "take precautions can cause problems",
            "reactions": [
                {
                    "reaction": {
                        "uuid": "1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                        "display": "Unknown",
                        "links": [
                            {
                                "rel": "self",
                                "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/concept/1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                            }
                        ]
                    },
                    "reactionNonCoded": null
                },
                {
                    "reaction": {
                        "uuid": "139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                        "display": "Headache",
                        "links": [
                            {
                                "rel": "self",
                                "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/concept/139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                            }
                        ]
                    },
                    "reactionNonCoded": null
                },
                {
                    "reaction": {
                        "uuid": "159098AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                        "display": "Hepatotoxicity",
                        "links": [
                            {
                                "rel": "self",
                                "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/concept/159098AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                            }
                        ]
                    },
                    "reactionNonCoded": null
                }
            ],
            "patient": {
                "uuid": "3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87",
                "display": "100J7W - AGB Ake",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87"
                    }
                ]
            },
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/2d440f27-7a87-4a14-bd21-efb5e99c58dc"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/2d440f27-7a87-4a14-bd21-efb5e99c58dc?v=full"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

List allergy subresource by its UUID and parent patient UUID.

List allergy subresource by its UUID and parent patient UUID

GET /patient/:target_patient_uuid/allergy/:target_allergy_uuid

var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  body: null,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/2d440f27-7a87-4a14-bd21-efb5e99c58dc", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/2d440f27-7a87-4a14-bd21-efb5e99c58dc")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7")
  .build();
Response response = client.newCall(request).execute();

Create a allergy sub resource with properties

Create a allergy sub resource

POST patient/:target_patient_uuid/allergy
{
    "allergen": {
        "allergenType": "DRUG",
        "codedAllergen": {
            "uuid": "162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        }
    },
    "severity": {
        "uuid": "1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
    },
    "comment": "severe allergy",
    "reactions": [
        {
            "reaction": {
                "uuid": "1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
            }
        },
        {
            "reaction": {
                "uuid": "139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
            }
        }
    ]
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"allergen\": {\r\n        \"allergenType\": \"DRUG\",\r\n        \"codedAllergen\": {\r\n            \"uuid\": \"162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n        }\r\n    },\r\n    \"severity\": {\r\n        \"uuid\": \"1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n    },\r\n    \"comment\": \"severe allergy\",\r\n    \"reactions\": [\r\n        {\r\n            \"reaction\": {\r\n                \"uuid\": \"1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n            }\r\n        },\r\n        {\r\n            \"reaction\": {\r\n                \"uuid\": \"139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n            }\r\n        }\r\n    ]\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7");

var raw = JSON.stringify({"allergen":{"allergenType":"DRUG","codedAllergen":{"uuid":"162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}},"severity":{"uuid":"1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},"comment":"severe allergy","reactions":[{"reaction":{"uuid":"1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}},{"reaction":{"uuid":"139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}}]});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Properties

Parameter type Description
allergen String value of the allergen (Required)
severity Severity_UUID Severity uuid
comment String comment in reference to the allergy
reaction reaction_UUID reaction uuid

Update allergy sub resource with properties

Update allergy sub resource

POST patient/:target_patient_uuid/allergy/:target_allergy_uuid
{
    "allergen": {
        "allergenType": "DRUG",
        "codedAllergen": {
            "uuid": "162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        }
    },
    "severity": {
        "uuid": "1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
    },
    "comment": "severe allergy",
    "reactions": [
        {
            "reaction": {
                "uuid": "1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
            }
        },
        {
            "reaction": {
                "uuid": "139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
            }
        }
    ]
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"allergen\": {\r\n        \"allergenType\": \"DRUG\",\r\n        \"codedAllergen\": {\r\n            \"uuid\": \"162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n        }\r\n    },\r\n    \"severity\": {\r\n        \"uuid\": \"1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n    },\r\n    \"comment\": \"severe allergy\",\r\n    \"reactions\": [\r\n        {\r\n            \"reaction\": {\r\n                \"uuid\": \"1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n            }\r\n        },\r\n        {\r\n            \"reaction\": {\r\n                \"uuid\": \"139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\r\n            }\r\n        }\r\n    ]\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/ba6e3813-1390-4b4d-9c0e-01de47bb7783")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7");

var raw = JSON.stringify({"allergen":{"allergenType":"DRUG","codedAllergen":{"uuid":"162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}},"severity":{"uuid":"1500AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},"comment":"severe allergy","reactions":[{"reaction":{"uuid":"1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}},{"reaction":{"uuid":"139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}}]});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/ba6e3813-1390-4b4d-9c0e-01de47bb7783", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Properties

Parameter type Description
allergen String value of the allergen
severity Severity_UUID Severity uuid
comment String comment for the allergy
reaction reaction_UUID reaction uuid

Delete allergy sub resource with properties

Delete allergy sub resource

DELETE /patient/:target_patient_uuid/allergy/:target_allergy_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/ba6e3813-1390-4b4d-9c0e-01de47bb7783?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=2375C8D206AB15F32A3FA3FEA5824BC7");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patient/3d808dc6-e9b8-4ade-b3fd-32bb0eb08f87/allergy/ba6e3813-1390-4b4d-9c0e-01de47bb7783?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

PatientIdentifierType

PatientIdentifierType Overview

Administrators define what types of identifiers they will collect. These range from National ID numbers, to driver's license numbers, to per-hospital medical record numbers.

Available operations for PatientIdentifierType

  1. List PatientIdentifierType resources
  2. Create a patientIdentifierType record
  3. Update a patientIdentifierType record
  4. Delete a patientIdentifierType record

List PatientIdentifierType resource

List PatientIdentifierType resource

GET /patientidentifiertype?v=default&limit=1

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patientidentifiertype?v=default&limit=1")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patientidentifiertype?v=default&limit=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "05a29f94-c0ed-11e2-94be-8c13b969e334",
            "display": "OpenMRS ID",
            "name": "OpenMRS ID",
            "description": "OpenMRS patient identifier, with check-digit",
            "format": null,
            "formatDescription": null,
            "required": true,
            "validator": "org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator",
            "locationBehavior": null,
            "uniquenessBehavior": null,
            "retired": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334",
                    "resourceAlias": "patientidentifiertype"
                },
                {
                    "rel": "full",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?v=full",
                    "resourceAlias": "patientidentifiertype"
                }
            ],
            "resourceVersion": "2.0"
        }
    ],
    "links": [
        {
            "rel": "next",
            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patientidentifiertype?limit=1&v=default&startIndex=1",
            "resourceAlias": null
        }
    ]
}

Get patientIdentifierType by UUID.

Get patientIdentifierType by UUID

GET /patientidentifiertype/:target_patientIdentifierType_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=ED9DBD5CFD355A973EFFECD642D8331D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a patientIdentifierType

Create a patientIdentifierType

POST /patientidentifiertype
{
    "name": "Wilson Hosp MRN",
    "description": "Wilson Hospital Medical Record Number",
    "format": "\\d{1,10}-\\d",
    "formatDescription": "Up to ten digts followed by a hyphen and another digit",
    "required": false,
    "validator": "org.openmrs.patient.impl.LuhnIdentifierValidator",
    "locationBehavior": "NOT_USED",
    "uniquenessBehavior": null
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"Wilson Hosp MRN\",\r\n    \"description\": \"Wilson Hospital Medical Record Number\",\r\n    \"format\": \"\\\\d{1,10}-\\\\d\",\r\n    \"formatDescription\": \"Up to ten digts followed by a hyphen and another digit\",\r\n    \"required\": false,\r\n    \"validator\": \"org.openmrs.patient.impl.LuhnIdentifierValidator\",\r\n    \"locationBehavior\": \"NOT_USED\",\r\n    \"uniquenessBehavior\": null\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patientidentifiertype")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();



var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var raw = JSON.stringify({"name":"Wilson Hosp MRN","description":"Wilson Hospital Medical Record Number","format":"\\d{1,10}-\\d","formatDescription":"Up to ten digts followed by a hyphen and another digit","required":false,"validator":"org.openmrs.patient.impl.LuhnIdentifierValidator","locationBehavior":"NOT_USED","uniquenessBehavior":null});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patientidentifiertype", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Properties

Parameter Type Description
name string label for the identifier (Required)
description string a small description about the patientIdentifier
format string a regular expression defining what the identifier text should contain
formatDescription string an optional description of the regular expression,(used to explain the requirements of the regular expression in terms a user would understand). For example, a regular expression like \d{4,8} could have a description like "Must be a number between 4 and 8 digits in length."
required boolean a true/false whether every patient must have this type
validator string full class name of an IdentifierValidator (e.g., org.openmrs.patient.impl.LuhnIdentifierValidator)

locationBehavior | "REQUIRED" or "NOT USED" | behavior of the location with respect to the identifier,"REQUIRED" if a location must be associated with the identifier; "NOT_USED" if the identifier does require a location

uniquenessBehavior | string | specify the uniqueness of the behaviour, it can be either Unique, Non Unique or Location.

Update a patientIdentifierType

Update a patientIdentifierType

POST /patientidentifertype/:target_patientidentifiertype_uuid
{
    "format": "\\d{1,10}-",
    "formatDescription": "Up to ten digts followed by a hyphen"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"format\": \"\\\\d{1,10}-\",\r\n    \"formatDescription\": \"Up to ten digts followed by a hyphen\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var raw = JSON.stringify({"format":"\\d{1,10}-","formatDescription":"Up to ten digts followed by a hyphen"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete a patientIdentifierType

Delete a patientIdentifierType

DELETE /patientidentifiertype/:target_patientidentifiertype_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=33B84B3BEA8E81E9D22D5A722815E010");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

PatientIdentifierSource

PatientIdentifierSource Overview

Available operations for PatientIdentifierSource

  1. List PatientIdentifierSources
  2. Create a PatientIdentifierSource
  3. Update a PatientIdentifierSource
  4. Delete a PatientIdentifierSource
  5. Export PatientIdentifiers from Source
  6. Reserve PatientIdentifiers in Source
  7. Upload PatientIdentifiers from Source
  8. Upload PatientIdentifiers from Request Body

List PatientIdentifierSources

List PatientIdentifierSource

GET /idgen/identifiersource?v=default
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/identifiersource?v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/identifiersource?v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response

{
    "results": [
        {
            "uuid": "691eed12-c0f1-11e2-94be-8c13b969e334",
            "name": "Generator for OpenMRS ID",
            "description": null,
            "baseCharacterSet": "0123456789ACDEFGHJKLMNPRTUVWXY",
            "prefix": null,
            "suffix": null,
            "firstIdentifierBase": "10000",
            "minLength": 6,
            "maxLength": null,
            "identifierType": {
                "uuid": "05a29f94-c0ed-11e2-94be-8c13b969e334",
                "display": "OpenMRS ID",
                "name": "OpenMRS ID",
                "description": "OpenMRS patient identifier, with check-digit",
                "format": null,
                "formatDescription": null,
                "required": true,
                "validator": "org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator",
                "locationBehavior": null,
                "uniquenessBehavior": null,
                "retired": false,
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334",
                        "resourceAlias": "patientidentifiertype"
                    },
                    {
                        "rel": "full",
                        "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?v=full",
                        "resourceAlias": "patientidentifiertype"
                    }
                ],
                "resourceVersion": "2.0"
            },
            "links": [
                {
                    "rel": "self",
                    "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/identifiersource/691eed12-c0f1-11e2-94be-8c13b969e334",
                    "resourceAlias": "identifiersource"
                }
            ],
            "type": "sequentialidentifiergenerator",
            "resourceVersion": "1.8"
        }
    ]
}

Returns list of all available PatientIdentifierSources.

Query Parameters

Parameter Type Description
identifierType PatientIdentifierType_UUID Source Identifier Type

List PatientIdentifierSource by UUID

List PatientIdentifierSource by UUID

GET /idgen/identifiersource/:uuid
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Retrieve PatientIdentifierSource by its UUID. Returns a 404 Not Found status if patient does not exist in the system. If the user is not logged in to perform this action, a 401 Unauthorized status is returned.

Create a PatientIdentifierSource

Create a PatientIdentifierSource

There are 3 types of PatientIdentifierSource you can create via REST API:

Create SequentialIdentifierGenerator

Create SequentialIdentifierGenerator

POST /idgen/identifiersource
{
    "sourceType": "SequentialIdentifierGenerator",
    "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
    "name": "New identifier",
    "description": "Description",
    "firstIdentifierBase": 10000,
    "baseCharacterSet": "0123456789ACDEFGHJKLMNPRTUVWXY",
    "prefix": "",
    "suffix": "",
    "minLength": 3,
    "maxLength": 10
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"sourceType\": \"SequentialIdentifierGenerator\",\n    \"identifierType\": \"05a29f94-c0ed-11e2-94be-8c13b969e334\",\n    \"name\": \"New identifier\",\n    \"description\": \"Description\",\n    \"firstIdentifierBase\": 10000,\n    \"baseCharacterSet\": \"0123456789ACDEFGHJKLMNPRTUVWXY\",\n    \"prefix\": \"\",\n    \"suffix\": \"\",\n    \"minLength\": 3,\n    \"maxLength\": 10\n}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/identifiersource")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();

var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var raw = JSON.stringify({"sourceType": "SequentialIdentifierGenerator","identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334","name": "New identifier","description": "Description","firstIdentifierBase": 10000,"baseCharacterSet": "0123456789ACDEFGHJKLMNPRTUVWXY","prefix": "","suffix": "","minLength": 3,"maxLength": 10});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/identifiersource", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

To create a SequentialIdentifierGenerator you need to specify the below properties. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Properties

Parameter Type Description
sourceType String Always set to "SequentialIdentifierGenerator" (Required)
identifierType PatientIdentifierType_UUID Source Identifier Type (Required)
name String Name (Required)
baseCharacterSet String Character set for generating identifiers (Required)
firstIdentifierBase integer Base of first generated identifier (Required)
description String Description
prefix String Identifier Prefix
suffix String Identifier Suffix
minLength integer Minimum Identifier length
maxLength integer Maximum Identifier length

Create RemoteIdentifierSource

Create RemoteIdentifierSource

POST /idgen/identifiersource                                                                                                                                                                                                                                                                                                                                                                                                                                                                
{
    "sourceType": "RemoteIdentifierSource",
    "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
    "name": "RemoteIdentifierSource",
    "description": "RemoteIdentifierSource",
    "url": "http://example.com",
    "username": "",
    "password": ""
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\n    \"sourceType\": \"RemoteIdentifierSource\",\n    \"identifierType\": \"05a29f94-c0ed-11e2-94be-8c13b969e334\",\n    \"name\": \"RemoteIdentifierSource\",\n    \"description\": \"RemoteIdentifierSource\",\n    \"url\": \"http://example.com\",\n    \"username\": \"\",\n    \"password\": \"\"\n}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"sourceType": "RemoteIdentifierSource", "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334","name": "RemoteIdentifierSource","description": "RemoteIdentifierSource","url": "http://example.com","username": "","password": ""});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

To create a RemoteIdentifierSource you need to specify the below properties. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Properties

Parameter Type Description
sourceType String Always set to "RemoteIdentifierSource" (Required)
identifierType PatientIdentifierType_UUID Source Identifier Type (Required)
name String Name (Required)
url URL Remote Source URL (Required)
description String Description
username String Remote Source Username
password String Remote Source Password

Create IdentifierPool

Create IdentifierPool

POST /idgen/identifiersource                                                                                                                                                                                                                                                                                                                                                                                                                                                                
{
    "sourceType": "IdentifierPool",
    "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
    "name": "IdentifierPool",
    "description": "IdentifierPool",
    "batchSize": 1000,
    "minPoolSize": 500,
    "sequential": true,
    "refillWithScheduledTask": false,
    "sourceUuid": ""
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\n    \"sourceType\": \"IdentifierPool\",\n    \"identifierType\": \"05a29f94-c0ed-11e2-94be-8c13b969e334\",\n    \"name\": \"IdentifierPool\",\n    \"description\": \"IdentifierPool\",\n    \"batchSize\": 1000,\n    \"minPoolSize\": 500,\n    \"sequential\": true,\n    \"refillWithScheduledTask\": false,\n    \"sourceUuid\": \"\"\n}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"sourceType": "IdentifierPool","identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334","name": "IdentifierPool","description": "IdentifierPool","batchSize": 1000,"minPoolSize": 500,"sequential": true,"refillWithScheduledTask": false,"sourceUuid": ""});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

To create an IdentifierPool you need to specify the below properties. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Properties

Parameter Type Description
sourceType String Always set to "IdentifierPool" (Required)
identifierType PatientIdentifierType_UUID Source Identifier Type (Required)
name String Name (Required)
description String Description
batchSize integer Batch Size
minPoolSize integer Minimum Pool Size
sequential String If true order is Sequential, if false order is Random
refillWithScheduledTask String If true pool is filled as a background task, if false, when you request an identifier
sourceUuid PatientIdentifierSource_UUID UUID of another source that you want to fill this pool from

Update a PatientIdentifierSource

Update a PatientIdentifierSource

There are 3 types of PatientIdentifierSource you can update via REST API:

Update SequentialIdentifierGenerator

Update SequentialIdentifierGenerator

POST /idgen/identifiersource/:uuid
{
    "name": "New identifier",
    "description": "Description",
    "firstIdentifierBase": 10000,
    "baseCharacterSet": "0123456789ACDEFGHJKLMNPRTUVWXY",
    "prefix": "",
    "suffix": "",
    "minLength": 3,
    "maxLength": 10
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"name\": \"New identifier\",\"description\": \"Description\",\"firstIdentifierBase\": 10000,\"baseCharacterSet\": \"0123456789ACDEFGHJKLMNPRTUVWXY\",\"prefix\": \"\",\"suffix\": \"\",\"minLength\": 3,\"maxLength\": 10}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var raw = JSON.stringify({"name": "New identifier","description": "Description","firstIdentifierBase": 10000,"baseCharacterSet": "0123456789ACDEFGHJKLMNPRTUVWXY","prefix": "","suffix": "","minLength": 3,"maxLength": 10});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

To update a SequentialIdentifierGenerator you need to specify the below properties. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Properties

Parameter Type Description
name String Name (Required)
baseCharacterSet String Character set for generating identifiers (Required)
firstIdentifierBase integer Base of first generated identifier (Required)
description String Description
prefix String Identifier Prefix
suffix String Identifier Suffix
minLength integer Minimum Identifier length
maxLength integer Maximum Identifier length

Update RemoteIdentifierSource

Update RemoteIdentifierSource

POST /idgen/identifiersource/:uuid                                                                                                                                                                                                                                                                                                                                                                                                                                                          
{
    "name": "RemoteIdentifierSource",
    "description": "RemoteIdentifierSource",
    "url": "http://example.com",
    "username": "",
    "password": ""
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\"name\": \"RemoteIdentifierSource\",\"description\": \"RemoteIdentifierSource\",\"url\": \"http://example.com\",\"username\": \"\",\"password\": \"\"} ");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"name": "RemoteIdentifierSource","description": "RemoteIdentifierSource","url": "http://example.com","username": "","password": ""} );                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

To update a RemoteIdentifierSource you need to specify the below properties. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Properties

Parameter Type Description
name String Name (Required)
url URL Remote Source URL (Required)
description String Description
username String Remote Source Username
password String Remote Source Password

Update IdentifierPool

Update IdentifierPool

POST /idgen/identifiersource/:uuid                                                                                                                                                                                                                                                                                                                                                                                                                                                      
{
    "name": "IdentifierPool",
    "description": "IdentifierPool",
    "batchSize": 1000,
    "minPoolSize": 500,
    "sequential": true,
    "refillWithScheduledTask": false,
    "sourceUuid": ""
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\"name\": \"IdentifierPool\",\"description\": \"IdentifierPool\",\"batchSize\": 1000,\"minPoolSize\": 500,\"sequential\": true,\"refillWithScheduledTask\": false,\"sourceUuid\": \"\"}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"name": "IdentifierPool","description": "IdentifierPool","batchSize": 1000,"minPoolSize": 500,"sequential": true,"refillWithScheduledTask": false,"sourceUuid": ""});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

To update an IdentifierPool you need to specify the below properties. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Properties

Parameter Type Description
name String Name (Required)
description String Description
batchSize integer Batch Size
minPoolSize integer Minimum Pool Size
sequential String If true order is Sequential, if false order is Random
refillWithScheduledTask String If true pool is filled as a background task, if false, when you request an identifier
sourceUuid PatientIdentifierSource_UUID UUID of another source that you want to fill this pool from

Delete a PatientIdentifierSource

Delete a PatientIdentifierSource

DELETE /idgen/identifiersource/:uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Deletes or retires a target PatientIdentifierSource by its UUID. Returns a 404 Not Found status if patient not exists. If the user is not logged in to perform this action, a 401 Unauthorized status returned.

Query Parameters

Parameter Type Description
uuid String UUID of PatientIdentifierSource to delete
purge Boolean The resource will be retired unless purge = 'true'

Export PatientIdentifiers from Source

Export PatientIdentifiers from Source

POST /idgen/identifiersource
{
    "generateIdentifiers": true,
    "sourceUuid": "691eed12-c0f1-11e2-94be-8c13b969e334",
    "numberToGenerate": 10
}
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\n    \"generateIdentifiers\": true,\n    \"sourceUuid\": \"691eed12-c0f1-11e2-94be-8c13b969e334\",\n    \"numberToGenerate\": 10\n}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"generateIdentifiers": true,"sourceUuid": "691eed12-c0f1-11e2-94be-8c13b969e334","numberToGenerate": 10});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

Success Response

{
    "identifiers": [
        "1018P3",
        "1018R1",
        "1018TY",
        "1018UW",
        "1018VU",
        "1018WR",
        "1018XN",
        "1018YL",
        "10190J",
        "10191G"
    ]
}

You can export new identifiers from given source in batch by POSTing with properties below:

Properties

Parameter Type Description
generateIdentifiers Boolean Always set to "true" (Required)
sourceUuid PatientIdentifierSource_UUID Source UUID to generate identifiers from
numberToGenerate integer Number of identifiers you want to generate

Reserve PatientIdentifiers in Source

Reserve PatientIdentifiers in Source

POST /idgen/identifiersource/:uuid
{
    "reservedIdentifiers": "10501A,10502A,10503A,10504A,10505A"
}
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\"reservedIdentifiers\": \"10501A,10502A,10503A,10504A,10505A\"}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"reservedIdentifiers": "10501A,10502A,10503A,10504A,10505A"});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

You can reserve number of provided identifiers by sending POST request with below properties:

Works only with SequentialIdentifierGenerator Source type!

Properties

Parameter Type Description
reservedIdentifiers String Identifiers to be reserved, divided by ","

Upload PatientIdentifiers from Source

Upload PatientIdentifiers from Source

POST /idgen/identifiersource/:uuid
{
    "operation": "uploadFromSource",
    "batchSize": 10
}
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\"operation\": \"uploadFromSource\",\"batchSize\": 10}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"operation": "uploadFromSource","batchSize": 10});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

You can fill pool of identifiers from another source by sending POST request with below properties:

Works only with IdentifierPool Source type with set "sourceUuid"!

Upload PatientIdentifiers from Request Body

Upload PatientIdentifiers from Request Body

POST /idgen/identifiersource/:uuid
{
    "operation": "uploadFromFile",
    "identifiers": "10501A,10502A,10503A,10504A,10505A"
}
OkHttpClient client = new OkHttpClient().newBuilder()                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MediaType mediaType = MediaType.parse("application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
RequestBody body = RequestBody.create(mediaType, "{\"operation\": \"uploadFromFile\",\"identifiers\": \"10501A,10502A,10503A,10504A,10505A\"}");                              
Request request = new Request.Builder()                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .url("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid")                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  .method("POST", body)                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")                                                                                                                                                                                                                                                                                                                                                                                                                                 
  .addHeader("Content-Type", "application/json")                                                                                                                                                                                                                                                                                                                                                                                                                                            
  .addHeader("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633")                                                                                                                                                                                                                                                                                                                                                                                                                       
  .build();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
Response response = client.newCall(request).execute();                                                                                                                                                                                                                                                                                                                                                                                                                                      
var requestHeaders = new Headers();                                                                                                                                                                                                                                                                                                                                                                                                                                                         
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");                                                                                                                                                                                                                                                                                                                                                                                                                       
requestHeaders.append("Content-Type", "application/json");                                                                                                                                                                                                                                                                                                                                                                                                                                  
requestHeaders.append("Cookie", "JSESSIONID=24D0761924138ED7E55C2CB6806B0633");                                                                                                                                                                                                                                                                                                                                                                                                             

var raw = JSON.stringify({"operation": "uploadFromFile","identifiers": "10501A,10502A,10503A,10504A,10505A"});                                                                                                                                                        

var requestOptions = {                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  method: 'POST',                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  headers: requestHeaders,                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  body: raw,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  redirect: 'follow'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

fetch("/openmrs/ws/rest/v1/idgen/identifiersource/:uuid", requestOptions)                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(response => response.text())                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  .then(result => console.log(result))                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  .catch(error => console.log('error', error));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

You can fill pool of identifiers from another source by sending POST request with below properties:

Works only with IdentifierPool Source type!

AutoGenerationOption

AutoGenerationOption Overview

AutoGenerationOption is a Resource which encapsulates the options for Auto-Generating a Patient Identifier.

Available operations for AutoGenerationOption

  1. List AutoGenerationOptions
  2. Create an AutoGenerationOption
  3. Update an AutoGenerationOption
  4. Delete an AutoGenerationOption

List AutoGenerationOptions

List AutoGenerationOptions

GET idgen/autogenerationoption?v=default
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/autogenerationoption?v=default
&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/autogenerationoption?v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response

{
    "results": [
        {
            "uuid": "b57bda1d-dbe5-436e-af0f-331be90fee4e",
            "identifierType": {
                "uuid": "05a29f94-c0ed-11e2-94be-8c13b969e334",
                "display": "OpenMRS ID",
                "name": "OpenMRS ID",
                "description": "OpenMRS patient identifier, with check-digit",
                "format": null,
                "formatDescription": null,
                "required": true,
                "validator": "org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator",
                "locationBehavior": null,
                "uniquenessBehavior": null,
                "retired": false,
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334",
                        "resourceAlias": "patientidentifiertype"
                    },
                    {
                        "rel": "full",
                        "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?v=full",
                        "resourceAlias": "patientidentifiertype"
                    }
                ],
                "resourceVersion": "2.0"
            },
            "location": null,
            "source": {
                "uuid": "691eed12-c0f1-11e2-94be-8c13b969e334",
                "name": "Generator for OpenMRS ID",
                "description": null,
                "baseCharacterSet": "0123456789ACDEFGHJKLMNPRTUVWXY",
                "prefix": null,
                "suffix": null,
                "firstIdentifierBase": "10000",
                "minLength": 6,
                "maxLength": null,
                "identifierType": {
                    "uuid": "05a29f94-c0ed-11e2-94be-8c13b969e334",
                    "display": "OpenMRS ID",
                    "name": "OpenMRS ID",
                    "description": "OpenMRS patient identifier, with check-digit",
                    "format": null,
                    "formatDescription": null,
                    "required": true,
                    "validator": "org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator",
                    "locationBehavior": null,
                    "uniquenessBehavior": null,
                    "retired": false,
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334",
                            "resourceAlias": "patientidentifiertype"
                        },
                        {
                            "rel": "full",
                            "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?v=full",
                            "resourceAlias": "patientidentifiertype"
                        }
                    ],
                    "resourceVersion": "2.0"
                },
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/identifiersource/691eed12-c0f1-11e2-94be-8c13b969e334",
                        "resourceAlias": "identifiersource"
                    }
                ],
                "type": "sequentialidentifiergenerator",
                "resourceVersion": "1.8"
            },
            "manualEntryEnabled": false,
            "automaticGenerationEnabled": true,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/autogenerationoption/b57bda1d-dbe5-436e-af0f-331be90fee4e",
                    "resourceAlias": "autogenerationoption"
                },
                {
                    "rel": "full",
                    "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/autogenerationoption/b57bda1d-dbe5-436e-af0f-331be90fee4e?v=full",
                    "resourceAlias": "autogenerationoption"
                }
            ],
            "resourceVersion": "1.8"
        }
    ]
}

Fetches list of AutoGenerationOptions. If not logged in to perform this action, a 401 Unauthorized status is returned.

Get AutoGenerationOption by UUID.

Get AutoGenerationOption by UUID

GET idgen/autogenerationoption/:uuid
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/autogenerationoption/:uuid
&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/autogenerationoption/:uuid", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Retrieves an AutoGenerationOption by its UUID. Returns a 404 Not Found status if the object does not exist. If not logged in to perform this action, a 401 Unauthorized status is returned.

Create an AutoGenerationOption

Create an AutoGenerationOption

POST idgen/autogenerationoption
{
    "source": "691eed12-c0f1-11e2-94be-8c13b969e334",
    "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
    "manualEntryEnabled": true,
    "automaticGenerationEnabled": true,
    "location": "2131aff8-2e2a-480a-b7ab-4ac53250262b"
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"source\": \"691eed12-c0f1-11e2-94be-8c13b969e334\",\"identifierType\": \"05a29f94-c0ed-11e2-94be-8c13b969e334\",\"manualEntryEnabled\": true,\"automaticGenerationEnabled\": true,\"location\": \"2131aff8-2e2a-480a-b7ab-4ac53250262b\"}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/autogenerationoption")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var raw = JSON.stringify({"source": "691eed12-c0f1-11e2-94be-8c13b969e334","identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334","manualEntryEnabled": true,"automaticGenerationEnabled": true,"location": "2131aff8-2e2a-480a-b7ab-4ac53250262b"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/autogenerationoption", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

You can create new instance of AutoGenerationOptions by POSTing to the endpoint above with properties below. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Attributes

Parameter Type Description
source PatientIdentifierSource_UUID Option's IdentifierSource (Required)
identifierType PatientIdentifierType_UUID Option's IdentifierType (Required)
manualEntryEnabled Boolean Is manual entry enabled for this identifier generator (Required)
automaticGenerationEnabled Boolean Is auto generation enabled for this identifier generator (Required)
location Location_UUID Location where these Options will be applicable (Optional)

Update an AutoGenerationOption

Update an AutoGenerationOption

POST idgen/autogenerationoption/:uuid
{
    "source": "691eed12-c0f1-11e2-94be-8c13b969e334",
    "manualEntryEnabled": true,
    "automaticGenerationEnabled": true,
    "location": "2131aff8-2e2a-480a-b7ab-4ac53250262b"
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"source\": \"691eed12-c0f1-11e2-94be-8c13b969e334\",\"manualEntryEnabled\": true,\"automaticGenerationEnabled\": true,\"location\": \"2131aff8-2e2a-480a-b7ab-4ac53250262b\"}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/autogenerationoption/:uuid")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var raw = JSON.stringify({"source": "691eed12-c0f1-11e2-94be-8c13b969e334","manualEntryEnabled": true,"automaticGenerationEnabled": true,"location": "2131aff8-2e2a-480a-b7ab-4ac53250262b"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/autogenerationoption/:uuid", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

You can update existing instance of AutoGenerationOptions by POSTing to the endpoint above with properties below. If object with given UUID doesn't exist, a 404 Not Found status is returned. If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Attributes

Parameter Type Description
source PatientIdentifierSource_UUID Option's IdentifierSource (Required)
manualEntryEnabled Boolean Is manual entry enabled for this identifier generator (Required)
automaticGenerationEnabled Boolean Is auto generation enabled for this identifier generator (Required)
location Location_UUID Location where these Options will be applicable (Optional)

Delete an AutoGenerationOption

Delete an AutoGenerationOption

DELETE idgen/autogenerationoption/:uuid?purge=true
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/autogenerationoption/:uuid?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=154692F02BBBC664825F3C4C224A474B")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("openmrs/ws/rest/v1/idgen/autogenerationoption/:uuid?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete (purge) AutoGenerationOptions by their UUID. Returns a 404 Not Found status if the object does not exist. If not logged in to perform this action, a 401 Unauthorized status is returned.

This resource cannot be voided/retired.

Patient Identifier LogEntry

LogEntry Overview

LogEntry is a resource that encapsulates Log entry for Patient Identifier generation event.

Available operations for LogEntry

  1. List LogEntries

List LogEntries

List LogEntries

GET idgen/logentry?v=default
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/logentry?v=default)
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/logentry?v=default", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response

{
  "results": [
    {
      "uuid": "10503A",
      "links": [
        {
          "rel": "self",
          "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/logentry/10503A",
          "resourceAlias": "logentry"
        },
        {
          "rel": "full",
          "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/logentry/10503A?v=full",
          "resourceAlias": "logentry"
        }
      ],
      "resourceVersion": "1.8",
      "source": {
        "uuid": "47ea53ab-e57a-4671-b2c8-63a4b31bb140",
        "name": "pool",
        "identifierType": {
          "uuid": "05a29f94-c0ed-11e2-94be-8c13b969e334",
          "display": "OpenMRS ID",
          "name": "OpenMRS ID",
          "description": "OpenMRS patient identifier, with check-digit",
          "format": null,
          "formatDescription": null,
          "required": true,
          "validator": "org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator",
          "locationBehavior": null,
          "uniquenessBehavior": null,
          "retired": false,
          "links": [
            {
              "rel": "self",
              "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334",
              "resourceAlias": "patientidentifiertype"
            },
            {
              "rel": "full",
              "uri": "http://localhost:8080/openmrs/ws/rest/v1/patientidentifiertype/05a29f94-c0ed-11e2-94be-8c13b969e334?v=full",
              "resourceAlias": "patientidentifiertype"
            }
          ],
          "resourceVersion": "2.0"
        },
        "display": "OpenMRS ID - pool - org.openmrs.module.idgen.IdentifierPool",
        "links": [
          {
            "rel": "self",
            "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/identifiersource/47ea53ab-e57a-4671-b2c8-63a4b31bb140",
            "resourceAlias": "identifiersource"
          }
        ],
        "type": "identifierpool",
        "resourceVersion": "1.8"
      },
      "identifier": "10503A",
      "comment": "Batch Export of 5 to file",
      "generatedBy": {
        "uuid": "1c3db49d-440a-11e6-a65c-00e04c680037",
        "display": "admin",
        "username": "admin",
        "systemId": "admin",
        "userProperties": {
          "loginAttempts": "0",
          "lockoutTimestamp": "",
          "emrapi.lastViewedPatientIds": "7,8"
        },
        "person": {
          "uuid": "1296b0dc-440a-11e6-a65c-00e04c680037",
          "display": "Super User",
          "links": [
            {
              "rel": "self",
              "uri": "http://localhost:8080/openmrs/ws/rest/v1/person/1296b0dc-440a-11e6-a65c-00e04c680037",
              "resourceAlias": "person"
            }
          ]
        },
        "privileges": [],
        "roles": [
          {
            "uuid": "8d94f852-c2cc-11de-8d13-0010c6dffd0f",
            "display": "System Developer",
            "links": [
              {
                "rel": "self",
                "uri": "http://localhost:8080/openmrs/ws/rest/v1/role/8d94f852-c2cc-11de-8d13-0010c6dffd0f",
                "resourceAlias": "role"
              }
            ]
          },
          {
            "uuid": "8d94f280-c2cc-11de-8d13-0010c6dffd0f",
            "display": "Provider",
            "links": [
              {
                "rel": "self",
                "uri": "http://localhost:8080/openmrs/ws/rest/v1/role/8d94f280-c2cc-11de-8d13-0010c6dffd0f",
                "resourceAlias": "role"
              }
            ]
          }
        ],
        "retired": false,
        "links": [
          {
            "rel": "self",
            "uri": "http://localhost:8080/openmrs/ws/rest/v1/user/1c3db49d-440a-11e6-a65c-00e04c680037",
            "resourceAlias": "user"
          },
          {
            "rel": "full",
            "uri": "http://localhost:8080/openmrs/ws/rest/v1/user/1c3db49d-440a-11e6-a65c-00e04c680037?v=full",
            "resourceAlias": "user"
          }
        ],
        "resourceVersion": "1.8"
      },
      "dateGenerated": "2021-06-25T21:37:33.000+0200"
    }
  ],
  "links": [
    {
      "rel": "next",
      "uri": "http://localhost:8080/openmrs/ws/rest/v1/idgen/logentry?v=default&startIndex=50",
      "resourceAlias": null
    }
  ]
}

You can also filter Log Entries with given query parameters. If not logged in to perform this action, a 401 Unauthorized status is returned.

Query Parameters

Parameter Type Description
source PatientIdentifierSource_UUID Filter entries by source
fromDate Date Filter entries older than date
toDate Date Filter entries younger than date
identifier String Filter entries by generated identifier
comment String Filter entries by generation event's comment
generatedBy User_UUID Filter entries by user who executed generation

Get LogEntry by Identifier

Get LogEntry by Identifier

GET idgen/logentry/:identifier
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/idgen/logentry/:identifier)
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/idgen/logentry/:identifier", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

You can also fetch log entry for a unique generated identifier.

Relationship Type

Relationship Type Overview

Relationship Types define the types of relationships between Persons. Also, manage how relationship types are shown to the user (which types are shown by default and in which order).

Relationships have two directions. Some relationships differ depending on the direction; for example, if A is related to B as "Parent", then B is, by definition, related to A as "Child". Other relationships are the same in either direction (e.g., the reverse relationship of "Sibling" is also "Sibling").

Available operations for Relationship Type

  1. List relationship types
  2. Create a relationship type
  3. Update a relationship type
  4. Delete a relationship type

List Relationship Types

Get all non-retired Relationship Types

GET /relationshiptype
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/relationshiptype
&v=default")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/relationshiptype", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response

{
    "results": [
        {
            "uuid": "8d919b58-c2cc-11de-8d13-0010c6dffd0f",
            "display": "Doctor/Patient",
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/relationshiptype/8d919b58-c2cc-11de-8d13-0010c6dffd0f",
                    "resourceAlias": "relationshiptype"
                }
            ]
        },
        {
            "uuid": "8d91a01c-c2cc-11de-8d13-0010c6dffd0f",
            "display": "Sibling/Sibling",
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/relationshiptype/8d91a01c-c2cc-11de-8d13-0010c6dffd0f",
                    "resourceAlias": "relationshiptype"
                }
            ]
        },
        {
            "uuid": "8d91a210-c2cc-11de-8d13-0010c6dffd0f",
            "display": "Parent/Child",
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/relationshiptype/8d91a210-c2cc-11de-8d13-0010c6dffd0f",
                    "resourceAlias": "relationshiptype"
                }
            ]
        },
        {
            "uuid": "8d91a3dc-c2cc-11de-8d13-0010c6dffd0f",
            "display": "Aunt/Uncle/Niece/Nephew",
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/relationshiptype/8d91a3dc-c2cc-11de-8d13-0010c6dffd0f",
                    "resourceAlias": "relationshiptype"
                }
            ]
        },
        {
            "uuid": "2a5f4ff4-a179-4b8a-aa4c-40f71956ebbc",
            "display": "Supervisor/Supervisee",
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/relationshiptype/2a5f4ff4-a179-4b8a-aa4c-40f71956ebbc",
                    "resourceAlias": "relationshiptype"
                }
            ]
        }
    ]
}

You can filter Relationship Types display with given query parameters. If not logged in to perform this action, a 401 Unauthorized status is returned.

Query Parameters

Parameter Type Description
q Search Query Filter relationship types by name

Get Relationship Type by UUID

Get Relationship Type by UUID

GET /relationshiptype/:uuid
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/relationshiptype/:uuid")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A2AF09658C73E1ECEC5D3C8C7C249A2D")
  .build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/relationshiptype/:uuid", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Retrieve a Relationship Type by its UUID. Returns a 404 Not Found status if the user does not exist. If not logged in to perform this action, a 401 Unauthorized status is returned.

Create a Relationship Type

Create a Relationship Type

{
    "description": "Relationship from a primary care provider to the patient",
    "aIsToB": "Doctor",
    "bIsToA": "Patient",
    "weight": 0
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"description\": \"Relationship from a primary care provider to the patient\",\"aIsToB\": \"Doctor\",\"bIsToA\": \"Patient\",\"weight\": 0}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/relationshiptype")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var raw = JSON.stringify({"description": "Relationship from a primary care provider to the patient","aIsToB": "Doctor","bIsToA": "Patient","weight": 0});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/relationshiptype", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

If you are not logged in to perform this action, a 401 Unauthorized status is returned.

Attributes

Parameter Type Description
aIsToB String How is A related to B
bIsToA String How is B related to A
description String Relationship description
weight integer Relationship weight

Update a Relationship Type

Update a Relationship Type using its UUID

POST /relationshiptype/:uuid
{
    "description": "Relationship between brother/sister, brother/brother, and sister/sister"
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"description\": \"Relationship between brother/sister, brother/brother, and sister/sister\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/relationshiptype/:uuid")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44")
  .build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "JSESSIONID=DF385B2E6E39E0BB49BB7E079BF31C44");

var raw = JSON.stringify({"description":"Relationship between brother/sister, brother/brother, and sister/sister"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/relationshiptype/:uuid", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Update a target Relationship Type with given UUID. Returns a 404 Not Found status if the Relationship Type does not exist. If not logged in to perform this action, a 401 Unauthorized status is returned.

Attributes

Parameter Type Description
aIsToB String How is A related to B
bIsToA String How is B related to A
description String Relationship description
weight integer Relationship weight

Delete a Relationship Type

Delete a Relationship Type using its UUID

DELETE /relationshiptype/:uuid?purge=true
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/relationshiptype/:uuid?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=154692F02BBBC664825F3C4C224A474B")
  .build();
Response response = client.newCall(request).execute();
var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=955E778A4F700C5AA9651DAF6FC9DDDA");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("https://demo.openmrs.org/openmrs/ws/rest/v1/relationshiptype/:uuid?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete or retire a Relationship Type by its UUID. Returns a 404 Not Found status if the Relationship Type does not exist. If not logged in to perform this action, a 401 Unauthorized status is returned.

Query Parameters

Parameter Type Description
purge Boolean The resource will be voided unless purge = ‘true’

Visits

Visits Overview

At the Amani Clinic, a patient might typically check-in at registration, be seen by a doctor, and receives medication dispensed in the pharmacy. This would be recorded as one visit of visit type of Outpatient and contain three encounters (Registration, Consultation, and Dispensing).

Visits Sub Resource types

Visits Attribute

Available operations for Visits

  1. List visits
  2. Create visit
  3. Update visit
  4. Delete visit
  5. List attribute subresource
  6. Create attribute subresource with properties
  7. Update attribute subresource
  8. Delete attribute subresource

List visits

List visits

GET /visit?includeInactive=true&fromStartDate=2016-10-08T04:09:23.000Z&v=default&limit=1

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit?includeInactive=true&fromStartDate=2016-10-08T04:09:23.000Z&v=default&limit=1")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit?includeInactive=true&fromStartDate=2016-10-08T04:09:23.000Z&v=default&limit=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "36475629-6652-44e9-a42b-c2b3b7438f72",
            "display": "Facility Visit @ Unknown Location - 18/01/2017 06:35",
            "patient": {
                "uuid": "c0cbe231-deb8-4cfa-89b4-8fb4570685fc",
                "display": "100DWN - Anthony López",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patient/c0cbe231-deb8-4cfa-89b4-8fb4570685fc",
                        "resourceAlias": "patient"
                    }
                ]
            },
            "visitType": {
                "uuid": "7b0f5697-27e3-40c4-8bae-f4049abfb4ed",
                "display": "Facility Visit",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/visittype/7b0f5697-27e3-40c4-8bae-f4049abfb4ed",
                        "resourceAlias": "visittype"
                    }
                ]
            },
            "indication": null,
            "location": {
                "uuid": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
                "display": "Unknown Location",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/location/8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
                        "resourceAlias": "location"
                    }
                ]
            },
            "startDatetime": "2017-01-18T06:35:03.000+0000",
            "stopDatetime": "2017-01-18T08:20:03.000+0000",
            "encounters": [
                {
                    "uuid": "bc8098b3-2da2-450d-be67-54024dcc5c2c",
                    "display": "Visit Note 18/01/2017",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/encounter/bc8098b3-2da2-450d-be67-54024dcc5c2c",
                            "resourceAlias": "encounter"
                        }
                    ]
                },
                {
                    "uuid": "cb35367a-5e98-4be6-9e97-ac575a29b194",
                    "display": "Vitals 18/01/2017",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/encounter/cb35367a-5e98-4be6-9e97-ac575a29b194",
                            "resourceAlias": "encounter"
                        }
                    ]
                }
            ],
            "attributes": [],
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/visit/36475629-6652-44e9-a42b-c2b3b7438f72",
                    "resourceAlias": "visit"
                },
                {
                    "rel": "full",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/visit/36475629-6652-44e9-a42b-c2b3b7438f72?v=full",
                    "resourceAlias": "visit"
                }
            ],
            "resourceVersion": "1.9"
        }
    ],
    "links": [
        {
            "rel": "next",
            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/visit?includeInactive=true&fromStartDate=2016-10-08T04%3A09%3A23.000Z&v=default&limit=1&startIndex=1",
            "resourceAlias": null
        }
    ]
}

Query Parameters

Parameter Type Description
patient Patient UUID Get visits for this patient
location Location UUID Get visits for this location
includeInactive Boolean Include inactive visits in the results
fromStartDate Date (ISO8601 Long) Include only visits with start date after fromStartDate

List visit by UUID.

List visit by UUID

GET /visit/:target_visit_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/36475629-6652-44e9-a42b-c2b3b7438f72")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/36475629-6652-44e9-a42b-c2b3b7438f72", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create visit

Create visit

POST /visit
{
    "patient": "0dfa22b0-6b35-4594-8c3c-7589ad40ed44",
    "visitType": "7b0f5697-27e3-40c4-8bae-f4049abfb4ed",
    "startDatetime": "2016-10-08T04:09:25.000Z",
    "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
    "indication": null,
    "encounters": [
        "37ecb524-6c5a-4793-a449-cab1be102199"
    ]
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"patient\": \"0dfa22b0-6b35-4594-8c3c-7589ad40ed44\",\r\n    \"visitType\": \"7b0f5697-27e3-40c4-8bae-f4049abfb4ed\",\r\n    \"startDatetime\": \"2016-10-08T04:09:25.000Z\",\r\n    \"location\": \"aff27d58-a15c-49a6-9beb-d30dcfc0c66e\",\r\n    \"indication\": null,\r\n    \"encounters\": [\r\n        \"37ecb524-6c5a-4793-a449-cab1be102199\"\r\n    ]\r\n}");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var raw = JSON.stringify({"patient":"0dfa22b0-6b35-4594-8c3c-7589ad40ed44","visitType":"7b0f5697-27e3-40c4-8bae-f4049abfb4ed","startDatetime":"2016-10-08T04:09:25.000Z","location":"aff27d58-a15c-49a6-9beb-d30dcfc0c66e","indication":null,"encounters":["37ecb524-6c5a-4793-a449-cab1be102199"]});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
patient Patient UUID Patient resource UUID (Required)
visitType Patient UUID Visit type resource UUID (Required)
startDatetime Date (ISO8601 Long) Start date of the visit
location Location UUID Location resource UUID
indication string Any indication of the visit
stopDatetime Date (ISO8601 Long) End date of the vist
encounters(#encounters) Array[]: Encounter UUID Encounter resources UUID
attributes(#visits-attribute-type) Array[]: Attribute List of visit attributes

Update visit

Update visit

POST /visit/:target_visit_uuid
{
    "startDatetime": "2019-10-08T04:09:25.000Z"
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"startDatetime\": \"2019-10-08T04:09:25.000Z\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/c298d3e1-6def-422a-9d0a-e18906a4ae73")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var raw = JSON.stringify({"startDatetime":"2019-10-08T04:09:25.000Z"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/c298d3e1-6def-422a-9d0a-e18906a4ae73", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
patient Patient UUID Patient resource UUID
visitType Patient UUID Visit type resource UUID
startDatetime Date (ISO8601 Long) Start date of the visit
location Location UUID Location resource UUID
indication string Any indication of the visit
stopDatetime Date (ISO8601 Long) End date of the vist
encounters(#encounters) Array[]: Encounter UUID Encounter resources UUID
attributes(#visits-attribute-type) Array[]: Attribute List of visit attributes

Delete visit

Delete visit

DELETE /visit/:target_visit_uuid?purge=true

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/c298d3e1-6def-422a-9d0a-e18906a4ae73?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/c298d3e1-6def-422a-9d0a-e18906a4ae73?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

List attribute subresources

List attribute subresources

GET /visit/:target_visit_uuid/attribute 

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "display": "Patient condition: normal condition",
            "uuid": "1162d82e-96b8-4e5b-9cdc-17393fc1044e",
            "attributeType": {
                "uuid": "77fd562e-4e35-4649-b57f-41c3b75882b3",
                "display": "Patient condition",
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/visitattributetype/77fd562e-4e35-4649-b57f-41c3b75882b3"
                    }
                ]
            },
            "value": "normal condition",
            "voided": false,
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e"
                },
                {
                    "rel": "full",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e?v=full"
                }
            ],
            "resourceVersion": "1.9"
        }
    ]
}

List attribute subresources by it's UUID and parent visit UUID.

List attribute subresources by it's UUID

GET /visit/:target_visit_uuid/attribute/:target_attribute_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create an attribute subresource

Create an attribute subresource


POST visit/:target_visit_uuid/attribute 
{
    "attributeType": "77fd562e-4e35-4649-b57f-41c3b75882b3",
    "value": "normal condition"
}


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"attributeType\": \"77fd562e-4e35-4649-b57f-41c3b75882b3\",\r\n    \"value\": \"normal condition\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270");

var raw = JSON.stringify({"attributeType":"77fd562e-4e35-4649-b57f-41c3b75882b3","value":"normal condition"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute", requestOptions)
  .then(response => response.text())


Attributes

Parameter Type Description
attributeType Attribute_Type UUID Create Attribute from this Attribute_Type (Required)
value Depends on Attribute_Type Selected Value for the attribute (Required)

Update attribute subresource

Update attribute subresource


POST visit/:target_visit_uuid/attribute/:target_attribute_uuid
{
    "value": "very critical"
} 


OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"value\": \"very critical\"\r\n} ");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270");

var raw = JSON.stringify({"value":"very critical"});

var requestOptions = {
  method: 'POST',
  headers: requestHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Attributes

Parameter Type Description
attributeType Attribute_Type UUID Attribute_Type resource UUID
updated value Depends on Attribute_Type Selected Updated value for the attribute

Delete attribute subresource

Delete attribute subresource

DELETE /visit/:target_visit_uuid/attribute/:target_attribute_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e?purge=true")
  .method("DELETE", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=A7DBC9603F0BAF39988C59B870111270");

var requestOptions = {
  method: 'DELETE',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visit/d29e005a-28d4-4b82-87dd-569ff2a4b8e9/attribute/1162d82e-96b8-4e5b-9cdc-17393fc1044e?purge=true", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Query Parameters

Parameter Type Description
purge Boolean The resource will be voided/retired unless purge = ‘true’

Visits Type

Visits Type Overview

Available operations for Visits Type

  1. List visits types
  2. Create a visit type
  3. Update a visit type
  4. Delete a visit type

list visits types

list visits types

GET /visittype?q=Facility&v=full

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visittype?q=Facility&v=full")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visittype?q=Facility&v=full", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Success Response


{
    "results": [
        {
            "uuid": "7b0f5697-27e3-40c4-8bae-f4049abfb4ed",
            "display": "Facility Visit",
            "name": "Facility Visit",
            "description": "Patient visits the clinic/hospital (as opposed to a home visit, or telephone contact)",
            "retired": false,
            "auditInfo": {
                "creator": {
                    "uuid": "A4F30A1B-5EB9-11DF-A648-37A07F9C90FB",
                    "display": "daemon",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/user/A4F30A1B-5EB9-11DF-A648-37A07F9C90FB",
                            "resourceAlias": "user"
                        }
                    ]
                },
                "dateCreated": "2013-08-02T00:39:43.000+0000",
                "changedBy": {
                    "uuid": "A4F30A1B-5EB9-11DF-A648-37A07F9C90FB",
                    "display": "daemon",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/user/A4F30A1B-5EB9-11DF-A648-37A07F9C90FB",
                            "resourceAlias": "user"
                        }
                    ]
                },
                "dateChanged": "2017-01-18T08:53:57.000+0000"
            },
            "links": [
                {
                    "rel": "self",
                    "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/visittype/7b0f5697-27e3-40c4-8bae-f4049abfb4ed",
                    "resourceAlias": "visittype"
                }
            ],
            "resourceVersion": "1.9"
        }
    ]
}

Query Parameters

Parameter Type Description
q Search Query Display Name of Visit Type.

List visit type by UUID.

List visit type by UUID

GET /visittype/:target_visit_type_uuid

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visittype/7b0f5697-27e3-40c4-8bae-f4049abfb4ed")
  .method("GET", null)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C");

var requestOptions = {
  method: 'GET',
  headers: requestHeaders,
  redirect: 'follow'
};

fetch("/openmrs/ws/rest/v1/visittype/7b0f5697-27e3-40c4-8bae-f4049abfb4ed", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Create a visit type

Create a visit type

POST /visittype
{
    "name": "Facility Visit",
    "description": "Patient visits the clinic/hospital (as opposed to a home visit, or telephone contact)"
}

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"Facility Visit\",\r\n    \"description\": \"Patient visits the clinic/hospital (as opposed to a home visit, or telephone contact)\"\r\n}\r\n");
Request request = new Request.Builder()
  .url("/openmrs/ws/rest/v1/visittype")
  .method("POST", body)
  .addHeader("Authorization", "Basic YWRtaW46QWRtaW4xMjM=")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F58327C")
  .build();
Response response = client.newCall(request).execute();


var requestHeaders = new Headers();
requestHeaders.append("Authorization", "Basic YWRtaW46QWRtaW4xMjM=");
requestHeaders.append("Content-Type", "application/json");
requestHeaders.append("Cookie", "JSESSIONID=1B06650EB0428F51EC119C909F5832