...
Code Block |
---|
/ws/rest/v1/session |
Create Person
The minium required fields are gender and names
PHP Code Example:-
Code Block |
---|
// PERSON $name = array(); $names = array(); $person_data = array(); $name['givenName'] = "givenName"; $name['middleName'] = "middleName"; $name['familyName'] = "familyName"; array_push($names,$name); $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); curl_close($person_curL); |
Create Patient
To create a patient, we can use the existing person or we can create a new person
PHP Example:-
Code Block |
---|
// PATIENT
$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;
array_push($person_identification,$identifiers);
$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);
curl_close($patient_curL); |
- Get people by name
Code Block |
---|
/ws/rest/v1/person?q=Akshika |
...