use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldAddRelatedResourcesWhenIncluded.
@Test
public void searchForRelatedPeople_shouldAddRelatedResourcesWhenIncluded() {
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("RelatedPerson:patient"));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includes)))).thenReturn(new MockIBundleProvider<>(Arrays.asList(relatedPerson, new Patient()), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.RELATED_PERSON));
assertThat(resultList.get(1).fhirType(), is(FhirConstants.PATIENT));
assertThat(resultList.size(), equalTo(2));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByCountry.
@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByCountry() {
StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(countryParam)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, null, countryParam, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByUUID.
@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByUUID() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(RELATED_PERSON_UUID));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(uuid)), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, null, null, uuid, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByGender.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByGender() {
TokenAndListParam genderParam = new TokenAndListParam().addAnd(new TokenOrListParam().add(GENDER));
when(relatedPersonService.searchForRelatedPeople(isNull(), argThat(is(genderParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, genderParam, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByState.
@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByState() {
StringAndListParam stateParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), argThat(is(stateParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, stateParam, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations