use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class TaskSearchQueryTest method searchForTasks_shouldReturnEmptyTaskListByMultipleStatusAnd.
@Test
public void searchForTasks_shouldReturnEmptyTaskListByMultipleStatusAnd() {
TokenAndListParam status = new TokenAndListParam().addAnd(new TokenOrListParam().add(FhirConstants.TASK_STATUS_VALUE_SET_URI, Task.TaskStatus.ACCEPTED.toString())).addAnd(new TokenOrListParam(FhirConstants.TASK_STATUS_VALUE_SET_URI, Task.TaskStatus.REQUESTED.toString()));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.STATUS_SEARCH_HANDLER, status);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class TaskSearchQueryTest method searchForTasks_shouldReturnTasksByStatus.
@Test
public void searchForTasks_shouldReturnTasksByStatus() {
TokenAndListParam status = new TokenAndListParam().addAnd(new TokenOrListParam().add(FhirConstants.TASK_STATUS_VALUE_SET_URI, Task.TaskStatus.ACCEPTED.toString()));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.STATUS_SEARCH_HANDLER, status);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList.size(), equalTo(2));
assertThat(resultList, hasItem(hasProperty("id", equalTo(TASK_UUID))));
assertThat(resultList, everyItem(hasProperty("status", equalTo(Task.TaskStatus.ACCEPTED))));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class TaskSearchQueryTest method searchForTasks_shouldHandleMultipleIncludes.
@Test
public void searchForTasks_shouldHandleMultipleIncludes() throws Exception {
executeDataSet(TASK_DATA_OWNER_XML);
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(TASK_REFF_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("Task:patient"));
includes.add(new Include("Task:owner"));
includes.add(new Include("Task:encounter"));
includes.add(new Include("Task:based-on"));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(resultList, not(empty()));
// included resource added as part of result list
assertThat(resultList.size(), equalTo(5));
assertThat(((Task) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(TASK_REFF_UUID));
Task returnedTask = (Task) resultList.iterator().next();
assertThat(resultList, hasItem(allOf(is(instanceOf(Patient.class)), hasProperty("id", equalTo(returnedTask.getFor().getReferenceElement().getIdPart())))));
assertThat(resultList, hasItem(allOf(is(instanceOf(Practitioner.class)), hasProperty("id", equalTo(returnedTask.getOwner().getReferenceElement().getIdPart())))));
assertThat(resultList, hasItem(allOf(is(instanceOf(Encounter.class)), hasProperty("id", equalTo(returnedTask.getEncounter().getReferenceElement().getIdPart())))));
assertThat(resultList, hasItem(allOf(is(instanceOf(ServiceRequest.class)), hasProperty("id", equalTo(returnedTask.getBasedOn().get(0).getReferenceElement().getIdPart())))));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class TaskSearchQueryTest method searchForTasks_shouldReturnEmptyListByMismatchingUuidAndLastUpdated.
@Test
public void searchForTasks_shouldReturnEmptyListByMismatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(TASK_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_RETIRED).setLowerBound(DATE_RETIRED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class PatientSearchQueryTest method searchForPatients_shouldSearchForPatientsByUuid.
@Test
public void searchForPatients_shouldSearchForPatientsByUuid() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PATIENT_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<Patient> resultList = get(results);
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(PATIENT_UUID));
}
Aggregations