Create Patient
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:
http://localhost:8086/openmrs/ws/rest/v1/patient
http://<your domain ip: port>/{APP-NAME}/ws/rest/v1/patient
The patient resource has its own unique representation. The following properties are found in the patient resource representation. You can find more information about available properties at REST Web Service Resources in OpenMRS 1.8.
Property | Value | Description |
---|---|---|
person | object | Person object which is associated with this patient |
identifiers | list of objects | List of unique patient identifiers |
Identifiers can be expanded to:
Property | Member | Value | Description |
---|---|---|---|
identifiers | identifier | string | Unique ID |
 | identifierType | object | Type of ID |
 | location | string |  |
 | preferred | boolean | Person must have at least one preferred ID |
Create patient
In order to create a patient you need to have an existing person or create one first with the following command:
POST /openmrs/ws/rest/v1/person
HEADER: Content-Type: application/json
BODY: {"gender": "M", "names": [{"givenName":"Joe", "familyName":"Smith"}]}
RESPONSE: a newly created person, e.g. with a generated UUID: "11f40a1b-0337-4652-86fa-18d4461e38a0"
From the above table you can also see that you will need to provide identifiers. Identifiers among other properties need to specify identifier type and location. You can find out about available patient identifier types requesting:
GET /openmrs/ws/rest/v1/patientidentifiertype
RESPONSE: a list of available identifier types, e.g. with UUIDs: "8d79403a-c2cc-11de-8d13-0010c6dffd0f", "f1b2e10e-035e-11e1-943f-ea16aa1464b8"
To find out about available locations request:
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:
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:
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.