Search in sources :

Example 96 with TokenAndListParam

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());
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 97 with TokenAndListParam

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))));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 98 with TokenAndListParam

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())))));
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) TokenParam(ca.uhn.fhir.rest.param.TokenParam) Include(ca.uhn.fhir.model.api.Include) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) HashSet(java.util.HashSet) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 99 with TokenAndListParam

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());
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 100 with TokenAndListParam

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));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) Patient(org.hl7.fhir.r4.model.Patient) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)357 Test (org.junit.Test)347 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)340 TokenParam (ca.uhn.fhir.rest.param.TokenParam)312 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)260 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)247 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)211 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)119 HashSet (java.util.HashSet)79 Include (ca.uhn.fhir.model.api.Include)77 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)48 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)48 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)46 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)46 NumberParam (ca.uhn.fhir.rest.param.NumberParam)36 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)36 Observation (org.hl7.fhir.r4.model.Observation)24 StringParam (ca.uhn.fhir.rest.param.StringParam)21 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)21 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)19