NAV Navbar
shell java python node.js

Current version

Resources

See documentation about resources and their URIs here: REST Web Service Resources in OpenMRS 1.9

Subresources

Examples :

Adding a person name.

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

Editing a person's name.

POST /openmrs/ws/rest/v1/person/target_person_uuid/name/target_name_uuid 
{
  "givenName": "Johnny"
}

Instead, these should be queries on the encounter resource:


 Get encounter list for specific patient.

 GET '/openmrs/ws/rest/v1/encounter?patient=target_patient_uuid'


 Get encounter list for specific location.

 GET '/openmrs/ws/rest/v1/encounter?location=target_location_uuid'

Resources with Subtypes

Examples :


POST /openmrs/ws/rest/v1/order
{"t": "testorder", /*... and other properties */}

 Get encounter orders of druge order sub type.

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

Authentication

Alternatively, a session token can be used to interact with the API endpoints.

Retrieve session token

GET /openmrs/ws/rest/v1/session 
-H 'Authorization: Basic Auth' (required to indetify the user)

This token should be passed with all subsequent calls as a cookie named jsessionid=token.

Logout User/End session

DELETE /openmrs/ws/rest/v1/session -H 'Accept: application/json'
-H 'Authorization: Basic Auth' (required to indetify the user)

Changing Password

Since version 2.17 of the webservices.rest module:

POST /openmrs/ws/rest/v1/password/target_user-UUID 
{
  "oldPassword" : "oldPassword",
  "newPassword" : "newPassword"
}
POST /openmrs/ws/rest/v1/password 
{
  "oldPassword" : "oldPassword",
  "newPassword" : "newPassword"
}

Getting all location without authentication

Fetching locations requires you to authenticate the user first .If it is required to display all locations prior to login or without authentication you can do it by

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

Patients

Patients Overview

Sub resource types of Patient

PatientIdentifier (Identifier)

Allergy

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

GET /patient?
country=india
&gender=M
GET /patient/:target_patient_uuid

Create a patient

POST /patient
{
    "person": "uuid",
    "identifiers": [
    {
        "identifier": "string",
        "identifierType": "uuid",
        "location": "uuid",
        "preferred": true
    }
    ]
}

Update a patient

Delete a patient

DELETE /patient/:target_patient_uuid?purge=true

List patientIdentifier sub resources

GET /patient/:target_patient_uuid/identifier
GET /patient/:target_patient_uuid/identifier/:target_identifier_uuid

Create a patientIdentifier sub resource with properties

POST patient/:target_patient_uuid/identifier
{ 
    "identifier" : "string",
    "identifierType" : "target_identifer_uuid",
    "location" : "target_location_uuid",
    "preferred" : true/false
}

Update patientIdentifier sub resource with properties

POST patient/:target_patient_uuid/identifier/:target_identifier_uuid
{ 
"identifier" : "string",
"identifierType" : "target_identifer_uuid",
"location" : "target_location_uuid",
"preferred" : true/false
}

Delete patientIdentifier sub resource with properties

DELETE /patient/:target_patient_uuid/identifier/:target_identifier_uuid

List allergy sub resources

GET /patient/:target_patient_uuid/allergy/:target_allergy_uuid

Create a allergy sub resource with properties

POST patient/:target_patient_uuid/allergy
{
    "allergen": {},
    "severity": {
        "uuid": "string"
    },
    "comment": "string",
    "reactions": [
        {
            "allergy": {
            "uuid": "string"
        },
        "reaction": {
            "uuid": "string"
        }
    }
]
}

Update allergy sub resource with properties

POST patient/:target_patient_uuid/allergy/:target_allergy_uuid
{
"allergen": {},
"severity": {
    "uuid": "string"
},
"comment": "string",
"reactions": [
    {
        "allergy": {
        "uuid": "string"
    },
    "reaction": {
        "uuid": "string"
    }
}
]
}

Delete allergy sub resource with properties

DELETE /patient/:target_patient_uuid/allergy/:target_allergy_uuid

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.

Properties on PatientIdentifierType:

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

GET /patientidentifiertype
GET /patientidentifiertype/:target_patientIdentifierType_uuid

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": true,
    "validator": "org.openmrs.patient.impl.LuhnIdentifierValidator",
    "checkDigit": true,
    "locationBehavior": "REQUIRED",
    "uniquenessBehavior": "Unique"
}

Update a patientIdentifierType

Delete a patientIdentifierType

DELETE /patientidentifiertype/:target_patientidentifiertype_uuid?purge=true

Visits

Visits Overview

Let’s look at an example of Visits

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 a visit
  3. Update a visit
  4. Delete a visit
  5. List attribute sub resource
  6. Create attribute sub resource with properties
  7. Update attribute sub resource
  8. Delete attribute sub resource

List visits

GET /visit?
includeInactive=true
&fromStartDate=2016-10-08T04:09:23.000Z
&patient=target_patient_uuid
&location=target_location_uuid
GET /visit/:target_visit_uuid

Create visit

POST /visit
{
    "patient": "target_patient_uuid",
    "visitType": "target_visitType_uuid",
    "startDatetime": "2016-10-08T04:09:25.000Z",
    "location": "target_location_uuid",
    "indication": null,
    "encounters": [
    "target_encounter_uuid"
    ],
    "attributes": [
    {
        "attributeType": "target_attributeType_uuid",
        "value": "value_for_attribute"
    }
    ]
}

Update visit

POST /visit/:target_visit_uuid
-d  modified_visit_object

Delete visit

DELETE /visit/:target_visit_uuid?purge=true

List attribute sub resources

GET /visit/:target_visit_uuid/attribute 
GET /visit/:target_visit_uuid/attribute/:target_attribute_uuid

Create an attribute sub resource with properties

POST visit/:target_visit_uuid/attribute 
{
    "attributeType": "target_attribute_type_uuid",
    "value": "value_for_the_attriute"
}

Update attribute sub resource

POST visit/:target_visit_uuid/attribute/:target_attribute_uuid
{
    "attributeType": "target_attribute_type_uuid",
    "value": "modified_attriute_value"
} 

Delete attribute sub resource

DELETE /visit/:target_visit_uuid/attribute/:target_attribute_uuid

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

GET /visittype?q="Search Query"
GET /visittype/:target_visit_type_uuid

Create a visit type

POST /visittype
{
    "name": "Name for the visit type",
    "description": "Description for the visit type"
}

Update a visit type

POST /type/:target_visit_type_uuid
{
    "name": "Modified name for the visit type",
    "description": "Modified description for the visit type"
}

Delete a visit type

DELETE /visittype/:target_visit_type_uuid?purge=true

Visits Attribute Type

Visits Attribute Type Overview

Available operations for Visits Attribute Type

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

List visits attribute types

GET /visitattributetype?q="Search Query"
GET /visitattributetype/:target_visit_attribute_type_uuid

Create a visit attribute type

POST /visitattributetype
{
  "name": "Patient condition",
  "description": "This attribute type will record the health conditon of the patient",
  "datatypeClassname": "org.openmrs.customdatatype.datatype.LongFreeTextDatatype",
  "minOccurs": 0,
  "maxOccurs": 1,
  "datatypeConfig": "default",
  "preferredHandlerClassname": "org.openmrs.web.attribute.handler.LongFreeTextTextareaHandler",
  "handlerConfig": "dafault"
}

Update a visit attribute type

POST /visitattributetype/:target_visit_attribute_type_uuid
{
  "name": "Patient condition modified",
  "description": "This attribute type will record the health conditon of the patient",
  "datatypeClassname": "org.openmrs.customdatatype.datatype.LongFreeTextDatatype",
  "minOccurs": 0,
  "maxOccurs": 2,
  "datatypeConfig": "default",
  "preferredHandlerClassname": "org.openmrs.web.attribute.handler.LongFreeTextTextareaHandler",
  "handlerConfig": "dafault"
}

Delete a visit attribute type

DELETE /visitattributetype/:target_visit_attribute_type_uuid?purge=true

Location

Location Overview

Location Sub Resource types

Location Attribute.

Available operations for Location

  1. List location
  2. Create a location
  3. Update a location
  4. Delete a location
  5. List location attribute sub resource
  6. Create location attribute sub resource with properties
  7. Update location attribute sub resource
  8. Delete location attribute sub resource

List location

GET /location?
q="amani"
GET /location/:target_location_uuid

Create a location

POST /location
{
    "name": "Salzburg Hospital",
    "description": "Salzburg hospital location",
    "address1": "Mullner House 48",
    "address2": "",
    "cityVillage": "salzburg",
    "stateProvince": "salzburg",
    "country": "Austria",
    "postalCode": "5020",
    "latitude": "",
    "longitude": "",
    "countyDistrict": "salzburg",
    "tags": [
    "target_location_tag_uuid"
    ],
    "parentLocation": "target_parent_location_uuid",
    "childLocations": [
    "target_child_location_uuid"
    ],
    "attributes": [
        {
            "attributeType": "target_attributeType_uuid",
            "value": "value_for_attribute"
        }
    ]
}

Update a location

POST /location/:target_location_uuid
{
    "name": "Salzburg Hospital",
    "description": "Modified location of Salzburg hospital location",
    "address1": "Mullner House 48",
    "address2": "",
    "cityVillage": "salzburg",
    "stateProvince": "salzburg",
    "country": "Austria",
    "postalCode": "5020",
    "latitude": "47.811195",
    "longitude": "13.03322",
    "countyDistrict": "salzburg",
    "tags": [
    "target_location_tag_uuid"
    ],
    "parentLocation": "target_parent_location_uuid",
    "childLocations": [
    "target_child_location_uuid"
    ],
    "attributes": [
        {
            "attributeType": "target_attributeType_uuid",
            "value": "value_for_attribute"
        }
    ]
}       

Delete a location

DELETE /location/:target_location_uuid?purge=true

List location attribute sub resources

GET /location/:target_location_uuid/attribute 
GET /location/:target_location_uuid/attribute/:target_attribute_uuid

Create a location attribute sub resource with properties

POST location/:target_location_uuid/attribute 
{
    "attributeType": "target_location_attribute_type_uuid",
    "value": "value_for_the_attriute"
}

Update a location attribute sub resource

POST location/:target_location_uuid/attribute/:target_location_attribute_uuid
{
    "attributeType": "target_attribute_type_uuid",
    "value": "modified_attriute_value"
} 

Delete a location attribute sub resource

DELETE /location/:target_location_uuid/attribute/:target_location_attribute_uuid

Location Tag Type

Location Tag Overview

Available operations for Location Tag

  1. List location tags
  2. Create a location tag
  3. Update a location tag
  4. Delete a location tag

List location tags

GET /locationtag?q="visit"
GET /locationtag/:target_location_tag_uuid

Create a location tag

POST /locationtag
{
  "name": "Visit Location",
  "description": "Visits are only allowed to happen at locations tagged with this location tag.",
  "retired": false
}

Update a location tag

POST /locationtag/:target_location_tag_uuid
{
  "name": "Visit Location",
  "description": "Visits are only allowed to happen at locations tagged with this location tag.",
  "retired": true,
  "retiredReason": "Not valid anymore"
}

Delete a location tag

DELETE /locationtag/:target_location_tag_uuid?purge=true

Location Attribute Type

Location Attribute Overview

Available operations for Location Attribute

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

List location attribute types

GET /locationattributetype?q="humidity"
GET /locationattributetype/:target_location_attribute_type_uuid

Create a location attribute type

POST /locationattributetype
{
  "name": "humidity",
  "description": "This attribute type will record the humidity of the location",
  "datatypeClassname": "org.openmrs.customdatatype.datatype.LongFreeTextDatatype",
  "minOccurs": 0,
  "maxOccurs": 1,
  "datatypeConfig": "default",
  "preferredHandlerClassname": "org.openmrs.web.attribute.handler.LongFreeTextTextareaHandler",
  "handlerConfig": "dafault"
}

Update a location attribute type

POST /locationattributetype/:target_location_attribute_type_uuid
{
  "name": "humidity",
  "description": "This attribute type will record the humidity of the location"",
  "datatypeClassname": "org.openmrs.customdatatype.datatype.LongFreeTextDatatype",
  "minOccurs": 0,
  "maxOccurs": 2,
  "datatypeConfig": "default",
  "preferredHandlerClassname": "org.openmrs.web.attribute.handler.LongFreeTextTextareaHandler",
  "handlerConfig": "dafault"
}

Delete a location attribute type

DELETE /locationattributetype/:target_location_attribute_type_uuid?purge=true

Encounters

Encounter Overview

Let’s look at an example of Encounter

During a typical Amani Clinic Outpatient Visit, a patient checks in at registration, is seen by a doctor, and receives medicine dispensed in the pharmacy. This would be recorded as one visit containing three encounters, whose types are Registration, Consultation, and Dispensing.

Sub Resource types of Encounter

Encounter Provider

Available operations for Encounter

  1. List encounters
  2. Create an encounters
  3. Update an encounters
  4. Delete an encounters
  5. List encounter provider sub resource
  6. Create encounter provider sub resource with properties
  7. Update encounter provider sub resource
  8. Delete encounter provider sub resource

List encounters

GET /encounter?
patient=96be32d2-9367-4d1d-a285-79a5e5db12b8
&fromdate=2016-10-08
GET /encounter/:target_encounter_uuid

Create an encounter

POST /encounter
{
  "encounterDatetime": "2019-10-16 12:08:43",
  "patient": "070f0120-0283-4858-885d-a20d967729cf",
  "encounterType": "e22e39fd-7db2-45e7-80f1-60fa0d5a4378",
  "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
  "encounterProviders": [
    {
      "provider": "bb1a7781-7896-40be-aaca-7d1b41d843a6",
      "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
    }
  ]
}

Update an encounter

POST /encounter/:target_encounter_uuid
{
  "encounterDatetime": "2019-10-16 12:08:43",
  "patient": "070f0120-0283-4858-885d-a20d967729cf",
  "encounterType": "e22e39fd-7db2-45e7-80f1-60fa0d5a4378",
  "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
  "encounterProviders": [
    {
      "provider": "bb1a7781-7896-40be-aaca-7d1b41d843a6",
      "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
    }
  ]
}

Delete an encounter

  DELETE /encounter/:target_encounter_uuid?purge=true

List encounter provider sub resources

GET /encounter/:target_encounter_uuid/encounterprovider 
GET /encounter/:target_encounter_uuid/encounterprovider/:target_encounter_provider_uuid

Create an encounter provider sub resource with properties

POST encounter/:target_encounter_uuid/encounterprovider 
{
  "provider": "bb1a7781-7896-40be-aaca-7d1b41d843a6",
  "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
}

Update encounter provider sub resource

POST encounter/:target_encounter_uuid/encounterprovider/:target_encounter_provider_uuid
{
  "provider": "bb1a7781-7896-40be-aaca-7d1b41d843a6",
  "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
}

Delete encounter provider sub resource

DELETE /encounter/:target_encounter_uuid/encounterprovider/:target_encounter_provider_uuid

Encounter Type

Encounter Type Overview

Available operations for Encounter Type

  1. List encounter types
  2. Create an encounter type
  3. Update an encounter type
  4. Delete an encounter type

List encounter types

GET /encountertype?
    q=Admission
GET /encountertype/:target_encounter_type_uuid

Create an encounter type

POST /encountertype
{
    "name": "Discharge",
    "description": "Attach encounters related to hospital dischargers"
}

Update an encounter type

POST /encountertype/:target_encounter_type_uuid
{
    "name": "Discharge",
    "description": "Encounters related to hospital dischargers"
}

Delete an encounter type

DELETE /encountertype/:target_encounter_type_uuid?purge=true

Encounter Role

Encounter Role Overview

Available operation for Encounter Roles

  1. List encounter roles
  2. Create an encounter role
  3. Update an encounter role
  4. Delete an encounter role

List encounter roles

GET /encounterrole?
    q=Clinician
    ```

* ### Get encounter role by UUID.

    Retrieve an encounter role by its UUID. Returns a `404 Not Found` status if encounter role not exists. If user not logged 
    in to perform this action, a `401 Unauthorized` status returned.

```console
GET /encounter/:target_encounter_role_uuid

Create an encounter role

POST /encounterrole
{
    "name": "Clinician",
    "description": "A provider assisting the Lead Surgeon."
}

Update an encounter role

POST /encounterrole/:target_encounter_role_uuid
{
    "name": "Assisting Surgeon"",
    "description": "A surgeon who assisted the Lead Surgeon"
}

Delete an encounter role

DELETE /encounterrole/:target_encounter_role_uuid?purge=true

Providers

Provider Overview

Sub Resource types of Provider

Provider Attribute.

Available operations for Provider.

  1. List providers
  2. Create a provider
  3. Update a provider
  4. Delete a provider
  5. List provider attribute sub resource
  6. Create provider attribute sub resource with properties
  7. Update provider attribute sub resource
  8. Delete provider attribute sub resource

List providers

GET /provider?
q=clerk
GET /provider/:target_provider_uuid

Create a provider

POST /provider
{
  "person": "007037a0-0500-11e3-8ffd-0800200c9a66",
  "identifier": "doctor",
  "attributes": [
    {
      "attributeType": "target_attributeType_uuid",
      "value": "value_for_attribute"
    }
  ],
  "retired": false
}

Update a provider

POST /provider/:target_provider_uuid
{
  "person": "007037a0-0500-11e3-8ffd-0800200c9a66",
  "identifier": "doctor",
  "attributes": [
    {
      "attributeType": "target_attributeType_uuid",
      "value": "value_for_attribute"
    }
  ],
  "retired": false
}

Delete a provider

DELETE /provider/:target_provider_uuid?purge=true

List provider attribute sub resources

GET /provider/:target_provider_uuid/attribute 
GET /provider/:target_provider_uuid/attribute/:target_provider_attribute_uuid

Create a provider attribute sub resource with properties

POST provider/:target_provider_uuid/attribute 
{
  "attributeType": "target_provider_attribute_type_uuid",
  "value": "New provider"
}

Update provider attribute sub resource

POST provider/:target_provider_uuid/attribute/:target_provider_attribute_uuid
{
    "attributeType": "target_provider_attribute_type_uuid",
    "value": "New provider"
}

Delete provider attribute sub resource

DELETE /provider/:target_provider_uuid/attribute/:target_provider_attribute_uuid