use of org.hl7.fhir.r4.model.AllergyIntolerance 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.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method updateAllergyIntolerance_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateAllergyIntolerance_shouldThrowInvalidRequestForMissingId() {
AllergyIntolerance noIdAllergyIntolerance = new AllergyIntolerance();
when(service.update(ALLERGY_UUID, noIdAllergyIntolerance)).thenThrow(InvalidRequestException.class);
resourceProvider.updateAllergy(new IdType().setValue(ALLERGY_UUID), noIdAllergyIntolerance);
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method getAllergyIntoleranceByUuid_shouldThrowResourceNotFoundException.
@Test(expected = ResourceNotFoundException.class)
public void getAllergyIntoleranceByUuid_shouldThrowResourceNotFoundException() {
IdType id = new IdType();
id.setValue(WRONG_ALLERGY_UUID);
AllergyIntolerance result = resourceProvider.getAllergyIntoleranceByUuid(id);
assertThat(result, nullValue());
}
use of org.hl7.fhir.r4.model.AllergyIntolerance 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));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByLastUpdated.
@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByLastUpdated() {
DateRangeParam dateRangeParam = new DateRangeParam().setLowerBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(dateRangeParam)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, null, null, dateRangeParam, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList.size(), greaterThanOrEqualTo(1));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Aggregations