use of org.hl7.fhir.dstu3.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleForMatchOnState.
@Test
public void shouldReturnCollectionOfRelatedPeopleForMatchOnState() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, stringAndListParam);
IBundleProvider relationships = search(theParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(1));
List<RelatedPerson> relationList = get(relationships);
assertThat(relationList, hasSize(equalTo(1)));
assertThat(relationList.get(0).getAddressFirstRep().getState(), equalTo(STATE));
}
use of org.hl7.fhir.dstu3.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnPersonName.
@Test
public void shouldReturnEmptyCollectionForNoMatchOnPersonName() {
StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_FOUND_NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, name);
IBundleProvider relations = search(theParams);
assertThat(relations, notNullValue());
assertThat(relations.size(), equalTo(0));
List<RelatedPerson> relationList = get(relations);
assertThat(relationList, empty());
}
use of org.hl7.fhir.dstu3.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByName.
@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByName() {
SortSpec sort = new SortSpec();
sort.setParamName(RelatedPerson.SP_NAME);
sort.setOrder(SortOrderEnum.ASC);
List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getNameFirstRep().getFamily(), lessThanOrEqualTo(relationshipList.get(i).getNameFirstRep().getFamily()));
}
sort.setOrder(SortOrderEnum.DESC);
relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getNameFirstRep().getFamily(), greaterThanOrEqualTo(relationshipList.get(i).getNameFirstRep().getFamily()));
}
}
use of org.hl7.fhir.dstu3.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByPostalCode.
@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByPostalCode() {
SortSpec sort = new SortSpec();
sort.setParamName(RelatedPerson.SP_ADDRESS_POSTALCODE);
sort.setOrder(SortOrderEnum.ASC);
List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getPostalCode(), lessThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getPostalCode()));
}
sort.setOrder(SortOrderEnum.DESC);
relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getPostalCode(), greaterThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getPostalCode()));
}
}
use of org.hl7.fhir.dstu3.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByState.
@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByState() {
SortSpec sort = new SortSpec();
sort.setParamName(RelatedPerson.SP_ADDRESS_STATE);
sort.setOrder(SortOrderEnum.ASC);
List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getState(), lessThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getState()));
}
sort.setOrder(SortOrderEnum.DESC);
relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getState(), greaterThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getState()));
}
}
Aggregations