use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelationsForMatchOnName.
@Test
public void shouldReturnCollectionOfRelationsForMatchOnName() {
StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, name);
IBundleProvider relations = search(theParams);
assertThat(relations, notNullValue());
assertThat(relations.size(), greaterThanOrEqualTo(1));
List<RelatedPerson> relationList = get(relations);
assertThat(relationList, hasSize(greaterThanOrEqualTo(1)));
assertThat(relationList.get(0).getNameFirstRep().getNameAsSingleString(), containsString(NAME));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnEmptyListByMismatchingUuidAndLastUpdated.
@Test
public void shouldReturnEmptyListByMismatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(RELATIONSHIP_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_VOIDED).setLowerBound(DATE_VOIDED);
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(0));
List<RelatedPerson> resultList = get(results);
assertThat(resultList, empty());
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method getRelationListForSorting.
private List<RelatedPerson> getRelationListForSorting(SortSpec sort) {
SearchParameterMap theParams = new SearchParameterMap().setSortSpec(sort);
IBundleProvider relationships = search(theParams);
assertThat(relationships, notNullValue());
List<RelatedPerson> relationList = get(relationships);
assertThat(relationList, hasSize(greaterThan(1)));
// Remove related persons with sort parameter value null, to allow comparison while asserting.
switch(sort.getParamName()) {
case RelatedPerson.SP_NAME:
relationList.removeIf(p -> p.getNameFirstRep() == null);
break;
case RelatedPerson.SP_BIRTHDATE:
relationList.removeIf(p -> p.getBirthDate() == null);
break;
case RelatedPerson.SP_ADDRESS_CITY:
relationList.removeIf(p -> p.getAddressFirstRep() == null || p.getAddressFirstRep().getCity() == null);
break;
case RelatedPerson.SP_ADDRESS_STATE:
relationList.removeIf(p -> p.getAddressFirstRep() == null || p.getAddressFirstRep().getState() == null);
break;
case RelatedPerson.SP_ADDRESS_POSTALCODE:
relationList.removeIf(p -> p.getAddressFirstRep() == null || p.getAddressFirstRep().getPostalCode() == null);
break;
case RelatedPerson.SP_ADDRESS_COUNTRY:
relationList.removeIf(p -> p.getAddressFirstRep() == null || p.getAddressFirstRep().getCountry() == null);
break;
}
assertThat(relationList, hasSize(greaterThan(1)));
return relationList;
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByCountry.
@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByCountry() {
SortSpec sort = new SortSpec();
sort.setParamName(RelatedPerson.SP_ADDRESS_COUNTRY);
sort.setOrder(SortOrderEnum.ASC);
List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getCountry(), lessThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getCountry()));
}
sort.setOrder(SortOrderEnum.DESC);
relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getCountry(), greaterThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getCountry()));
}
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByCity.
@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByCity() {
SortSpec sort = new SortSpec();
sort.setParamName(RelatedPerson.SP_ADDRESS_CITY);
sort.setOrder(SortOrderEnum.ASC);
List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getCity(), lessThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getCity()));
}
sort.setOrder(SortOrderEnum.DESC);
relationshipList = getRelationListForSorting(sort);
for (int i = 1; i < relationshipList.size(); i++) {
assertThat(relationshipList.get(i - 1).getAddressFirstRep().getCity(), greaterThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getCity()));
}
}
Aggregations