abtimo
(Abtimo SARL)
December 25, 2016, 3:40pm
#1
Hello All
I am looking for the way to search for past and future scheduled drug orders using REST API
While there is many useful samples how to do it with java, it’s still requires documenting as per comments for the original wiki post :
https://wiki.openmrs.org/display/docs/Order+Entry+API
In concrete terms, while there is the very easy way to retrieve all active orders using
/openmrs/ws/rest/v1/order?patient=efaab948-b3fa-4553-9c84-81594c91617e
I can not figure out how to search for orders with asOf date in the past or in the future.
Maybe it can be achieved via order search or am i supposed to retrieve all encounters and go trough the graph looking for dates and doing manual filtering?
Thank you in advance.
dkayiwa
(Daniel Kayiwa)
December 25, 2016, 5:55pm
#2
@abtimo did you get a chance to look at these tests?
@Test
public void shouldGetTheActiveOrdersForAPatientInTheSpecifiedCareSetting() throws Exception {
String expectedOrderUuid = orderService.getOrder(222).getUuid();
SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("patient",
"da7f524f-27ce-4bb2-86d6-6d1d05312bd5"),
new Parameter("careSetting", "c365e560-c3ec-11e3-9c1a-0800200c9a66"))));
assertEquals(1, Util.getResultsSize(results));
assertEquals(expectedOrderUuid, PropertyUtils.getProperty(Util.getResultsList(results).get(0), "uuid"));
}
@Test
public void shouldGetTheActiveOrdersForAPatientAsOfTheSpecifiedDate() throws Exception {
SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("patient", patientService
.getPatient(2).getUuid()), new Parameter("asOfDate", "2007-12-10"))));
assertEquals(2, Util.getResultsSize(results));
results = deserialize(handle(newGetRequest(getURI(),
new Parameter("patient", patientService.getPatient(2).getUuid()), new Parameter("asOfDate",
"2007-12-10 00:01:00"))));
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9;
import java.util.List;
import org.apache.commons.beanutils.PropertyUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.DrugOrder;
import org.openmrs.Order;
import org.openmrs.Patient;
This file has been truncated. show original