use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByLastUpdated.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByLastUpdated() {
DateRangeParam lastUpdated = new DateRangeParam().setLowerBound(LAST_UPDATED_DATE).setUpperBound(LAST_UPDATED_DATE);
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(lastUpdated)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, null, null, lastUpdated, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method getPatientResourceHistory_shouldReturnListOfResource.
@Test
public void getPatientResourceHistory_shouldReturnListOfResource() {
IdType id = new IdType();
id.setValue(PERSON_UUID);
when(fhirPersonService.get(PERSON_UUID)).thenReturn(person);
List<Resource> resources = resourceProvider.getPersonHistoryById(id);
assertThat(resources, notNullValue());
assertThat(resources, not(empty()));
assertThat(resources.size(), equalTo(2));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method getPersonById_shouldReturnPerson.
@Test
public void getPersonById_shouldReturnPerson() {
IdType id = new IdType();
id.setValue(PERSON_UUID);
when(fhirPersonService.get(PERSON_UUID)).thenReturn(person);
Person result = resourceProvider.getPersonById(id);
assertThat(result.isResource(), is(true));
assertThat(result, notNullValue());
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(PERSON_UUID));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method initPerson.
@Before
public void initPerson() {
HumanName name = new HumanName();
name.addGiven(GIVEN_NAME);
name.setFamily(FAMILY_NAME);
person = new org.hl7.fhir.r4.model.Person();
person.setId(PERSON_UUID);
person.setGender(Enumerations.AdministrativeGender.MALE);
person.addName(name);
setProvenanceResources(person);
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByCity.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByCity() {
StringAndListParam cityParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), argThat(is(cityParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, cityParam, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations