Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

This page is out of date. E.g. with modern versions of the OpenMRS REST API it is not necessary to create a person and then a patient in two separate POSTs.

 

You can access the patient resource via the following URL:

Code Block

http://localhost:8086/openmrs/ws/rest/v1/patient
http://<your domain ip: port>/{APP-NAME}/ws/rest/v1/patient

...

Property
Name

Value

Description

person
required 

object

Person object which is associated with this patient

identifiers
required

list of objects

List of unique patient identifiers

Identifiers can be expanded to:

Property 
Name

Member
Name

Value

Description

identifiers

identifier 
required

string

Unique ID

 

identifierType
required

object

Type of ID

 

location
required

string

 

 

preferred
optional

boolean

Person must have at least one preferred ID

...

Code Block
GET /openmrs/ws/rest/v1/location
RESPONSE: a list of locations, e.g. with UUIDs: "8d6c993e-c2cc-11de-8d13-0010c6dffd0f"

You will also need to have a pre-generated identifier for your patient. If you are developing against Reference Application or any distribution, which uses the IDGEN module for patient identifier generation, you will need to send a regular get request. Unfortunately it is not yet exposed as a rest resource (see IDGEN-42). You can use this request for example:

Code Block
GET openmrs/module/idgen/generateIdentifier.form?source=1&username=admin&password=Admin123
RESPONSE: identifier

Finally you can create a patient for the existing person with UUID "11f40a1b-0337-4652-86fa-18d4461e38a0", identifierType "8d79403a-c2cc-11de-8d13-0010c6dffd0f" and location "8d6c993e-c2cc-11de-8d13-0010c6dffd0f" with the following command:

...

You can test the above commands using a command line tool like curl. You will need to call it as follows:

Code Block

echo '{

	"identifiers": [
		{
		  "identifier":"1234", 
		  "identifierType":"8d79403a-c2cc-11de-8d13-0010c6dffd0f", 
		  "location":"8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
		  "preferred":true
		} ],
	"person":"11f40a1b-0337-4652-86fa-18d4461e38a0"

}' | curl i -u admin:test -H "Content-type: application/json" -X POST -d @ http://localhost:8086/openmrs/ws/rest/v1/patient

JavaScript example

You can also follow this example implemented using jQuery.

Update patient

The patient resource allows only for editing identifiers. You cannot change the associated person to some other person or any of person's properties. That said if you want to update the birthdate or any other property of a person you need to POST to the person resource.