use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByStatus.
@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByStatus() {
TokenAndListParam status = new TokenAndListParam();
status.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue("active")));
when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(status)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, status, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByManifestation.
@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByManifestation() {
TokenAndListParam manifestation = new TokenAndListParam();
manifestation.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODED_REACTION_UUID)));
when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), argThat(is(manifestation)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, manifestation, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesBySeverity.
@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesBySeverity() {
TokenAndListParam severity = new TokenAndListParam();
severity.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(SEVERITY_CONCEPT_UUID)));
when(service.searchForAllergies(isNull(), isNull(), isNull(), argThat(is(severity)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, severity, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyInclude.
@Test
public void searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyInclude() {
HashSet<Include> includes = new HashSet<>();
when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.size(), greaterThanOrEqualTo(1));
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByAllergen.
@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByAllergen() {
TokenAndListParam allergen = new TokenAndListParam();
allergen.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODED_ALLERGEN_UUID)));
when(service.searchForAllergies(isNull(), isNull(), argThat(is(allergen)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, allergen, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Aggregations