Sample REST calls

Authenticate and get a session ID and whether the authentication was successful or not. This is useful to verify connectivity and credentials.





Create Person

   The minium required fields are gender and names

          PHP Code Example:-

   // PERSON
   $name        = array();
   $names       = array();
   $person_data = array(); 

   $name['givenName']  = "givenName";
   $name['middleName'] = "middleName";
   $name['familyName'] = "familyName";

   $person_data['gender']    = "gender";    // Say "M"
   $person_data['names']     = $names;
   $person_data = json_encode($person_data);

   $person_curL = curl_init('http://localhost/openmrs-standalone/ws/rest/v1/person');
   curl_setopt($person_curL, CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
   curl_setopt($person_curL, CURLOPT_USERPWD,"admin:Admin123");
   curl_setopt($person_curL, CURLOPT_RETURNTRANSFER,true);
   curl_setopt($person_curL, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); 
   curl_setopt($person_curL, CURLOPT_POST,1);
   curl_setopt($person_curL, CURLOPT_POSTFIELDS,$person_data);
   $output   = curl_exec($person_curL);
   $status   = curl_getinfo($person_curL,CURLINFO_HTTP_CODE);


Create Patient
     To create a patient, we can use the existing person or we can create a new person

PHP Example:-


$identifiers           = array();
$person_data           = array();
$person_identification = array();

$identifiers['identifier']     = "identifier";                   // user defined
$identifiers['identifierType'] = "uuid of the identifier type"; // Either Old Identification number or OpenMRS Identification Number
$identifiers['location']       = "uuid of the location";
$identifiers['preferred']      = true;
$patient_data['person']      = "uuid of the person";          // Existing person's uuid or newly created person's uuid  
$patient_data['identifiers'] = $person_identification;

$patient_data = json_encode($patient_data);

$patient_curL = curl_init('http://localhost/openmrs-standalone/ws/rest/v1/patient');
curl_setopt($patient_curL, CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
curl_setopt($patient_curL, CURLOPT_USERPWD,"admin:Admin123");
curl_setopt($patient_curL, CURLOPT_RETURNTRANSFER,true);
curl_setopt($patient_curL, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); 
curl_setopt($patient_curL, CURLOPT_POST,1);
curl_setopt($patient_curL, CURLOPT_POSTFIELDS,$patient_data);
$patientoutput  = curl_exec($patient_curL);
$patientstatus  = curl_getinfo($patient_curL,CURLINFO_HTTP_CODE);



  1. Get people by name

Please add your own REST calls that you find useful.

You can find more examples in our controller tests at



Call Type
Sample URL
GET/ws/rest/v1/conceptReturns a list of top 50 (whatever is configured in settings (formerly Global Properties from 1.8 downwards)) concepts with uuid, display and links
GET/ws/rest/v1/concept?v=custom:(uuid,name)Returns a list of top 50 (whatever is configured in settings (formerly Global Properties from 1.8 downwards)) concepts

Returns full description of a concept, including:
uuid, name, display, datatype, conceptClass, set, version, retired, names, mappings, etc.

GET/ws/rest/v1/concept?q=YesReturns list of concepts matching "Yes" with uuid, display and links

Returns list of concepts matching "COUGH" with uuid and name


Encounter Type

Call Type
Sample URL
GET/ws/rest/v1/encountertypeReturns a list of top 50 encounter types with uuid, display and links
GET/ws/rest/v1/encountertype?q=admissionReturns encounter type admission with uuid, display and links