use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnCollectionOfPersonWhenPersonCountryMatched.
@Test
public void searchForRelatedPeople_shouldReturnCollectionOfPersonWhenPersonCountryMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(singletonList(RELATED_PERSON_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(singletonList(relationship));
when(translator.toFhirResource(relationship)).thenReturn(relatedPerson);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = relatedPersonService.searchForRelatedPeople(null, null, null, null, null, null, stringAndListParam, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnCollectionOfRelatedPersonWhenPersonStateMatched.
@Test
public void searchForRelatedPeople_shouldReturnCollectionOfRelatedPersonWhenPersonStateMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(singletonList(RELATED_PERSON_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(singletonList(relationship));
when(translator.toFhirResource(relationship)).thenReturn(relatedPerson);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = relatedPersonService.searchForRelatedPeople(null, null, null, null, stringAndListParam, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnCollectionOfRelatedPersonWhenPersonBirthDateMatched.
@Test
public void searchForRelatedPeople_shouldReturnCollectionOfRelatedPersonWhenPersonBirthDateMatched() throws ParseException {
Date birthDate = dateFormatter.parse(PERSON_BIRTH_DATE);
person.setBirthdate(birthDate);
DateRangeParam dateRangeParam = new DateRangeParam().setLowerBound(PERSON_BIRTH_DATE).setUpperBound(PERSON_BIRTH_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, dateRangeParam);
when(dao.getSearchResultUuids(any())).thenReturn(singletonList(RELATED_PERSON_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(singletonList(relationship));
when(translator.toFhirResource(relationship)).thenReturn(relatedPerson);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = relatedPersonService.searchForRelatedPeople(null, null, dateRangeParam, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class FhirRelatedPersonServiceImplTest method setup.
@Before
public void setup() {
relatedPersonService = new FhirRelatedPersonServiceImpl() {
@Override
protected void validateObject(Relationship object) {
}
};
relatedPersonService.setDao(dao);
relatedPersonService.setTranslator(translator);
relatedPersonService.setSearchQuery(searchQuery);
relatedPersonService.setSearchQueryInclude(searchQueryInclude);
PersonName name = new PersonName();
name.setUuid(PERSON_NAME_UUID);
name.setGivenName(GIVEN_NAME);
name.setFamilyName(FAMILY_NAME);
PersonAddress address = new PersonAddress();
address.setCityVillage(CITY);
address.setStateProvince(STATE);
address.setPostalCode(POSTAL_CODE);
address.setCountry(COUNTRY);
person = new org.openmrs.Person();
person.setUuid(PERSON_UUID);
person.setGender("M");
person.addName(name);
relationship = new org.openmrs.Relationship();
relationship.setRelationshipId(1000);
relationship.setPersonA(person);
HumanName humanName = new HumanName();
humanName.addGiven(GIVEN_NAME);
humanName.setFamily(FAMILY_NAME);
humanName.setId(PERSON_NAME_UUID);
Address relatedPersonAddress = new Address();
relatedPersonAddress.setCity(CITY);
relatedPersonAddress.setState(STATE);
relatedPersonAddress.setPostalCode(POSTAL_CODE);
relatedPersonAddress.setCountry(COUNTRY);
relatedPerson = new RelatedPerson();
relatedPerson.addName(humanName);
relatedPerson.addAddress(relatedPersonAddress);
relatedPerson.setGender(Enumerations.AdministrativeGender.MALE);
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleByMatchingUuidAndLastUpdated.
@Test
public void shouldReturnCollectionOfRelatedPeopleByMatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(RELATIONSHIP_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CREATED).setLowerBound(DATE_CREATED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<RelatedPerson> resultList = get(results);
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(RELATIONSHIP_UUID));
}
Aggregations