/
API Usage Examples
API Usage Examples
Getting Observations
An example of how to get all observations for a patient. We use the API method for getting observations:
List<Obs> getObservations(List<Person> whom, List<Encounter> encounters, List<Concept> questions,
List<Concept> answers, List<PERSON_TYPE> personTypes, List<Location> locations, List<String> sort,
Integer mostRecentN, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs)
throws APIException;
To get all observations for a person:
import org.openmrs.Person;
import org.openmrs.Obs;
// Create a list with one person
List<Person> personList = new ArrayList<Person>();
personList.add(Context.getPersonService().getPerson(4562)) // using a random person ID for example
// Get all observations for person 4562 that are not voided
List<Obs> obsList = Context.getObsService().
getObservations(personList, null, null, null, null, null, null, null, null, null, null, false);
// obsList now contains all non-voided observations for person 4562
More API resources
To learn more about OpenMRS API, visit How to Use OpenMRS API and OpenMRS API Doc.
, multiple selections available,
Related content
Best Practices for Implementations
Best Practices for Implementations
More like this
REST Module
REST Module
Read with this
Adding a Web Service Step by Step Guide for Module Developers
Adding a Web Service Step by Step Guide for Module Developers
Read with this
Modules
Modules
Read with this
Reference Application 2.3
Reference Application 2.3
More like this
Reference Application 2.5
Reference Application 2.5
More like this