use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest 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<AllergyIntolerance> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getId(), equalTo(ALLERGY_UUID));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest method getAllergyIntoleranceHistory_shouldReturnProvenanceResources.
@Test
public void getAllergyIntoleranceHistory_shouldReturnProvenanceResources() {
IdType id = new IdType();
id.setValue(ALLERGY_UUID);
when(service.get(ALLERGY_UUID)).thenReturn(allergyIntolerance);
List<Resource> resources = resourceProvider.getAllergyIntoleranceHistoryById(id);
assertThat(resources, not(empty()));
assertThat(resources.stream().findAny().isPresent(), is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest method createAllergyIntolerance_shouldCreateNewAllergyIntolerance.
@Test
public void createAllergyIntolerance_shouldCreateNewAllergyIntolerance() {
when(service.create(any(org.hl7.fhir.r4.model.AllergyIntolerance.class))).thenReturn(allergyIntolerance);
MethodOutcome result = resourceProvider.creatAllergyIntolerance(AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance));
assertThat(result, notNullValue());
assertThat(result.getCreated(), is(true));
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest method searchForAllergies_shouldAddPatientsToReturnedResultsForPatientInclude.
@Test
public void searchForAllergies_shouldAddPatientsToReturnedResultsForPatientInclude() {
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("AllergyIntolerance:patient"));
when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includes)))).thenReturn(new MockIBundleProvider<>(Arrays.asList(allergyIntolerance, new org.hl7.fhir.r4.model.Patient()), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(results, notNullValue());
assertThat(resultList.size(), greaterThanOrEqualTo(2));
assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
assertThat(resultList.get(1).fhirType(), is(FhirConstants.PATIENT));
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 AllergyIntoleranceFhirR3ResourceProviderTest method updateAllergyIntolerance_shouldUpdateAllergyIntolerance.
@Test
public void updateAllergyIntolerance_shouldUpdateAllergyIntolerance() {
when(service.update(eq(ALLERGY_UUID), any(org.hl7.fhir.r4.model.AllergyIntolerance.class))).thenReturn(allergyIntolerance);
MethodOutcome result = resourceProvider.updateAllergyIntolerance(new IdType().setValue(ALLERGY_UUID), AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance));
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
}
Aggregations