use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelationsForMatchingGenderOfRelatedPerson.
@Test
public void shouldReturnCollectionOfRelationsForMatchingGenderOfRelatedPerson() {
TokenAndListParam gender = new TokenAndListParam().addAnd(new TokenOrListParam().add(MALE_GENDER));
SearchParameterMap maleGenderParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, gender);
IBundleProvider relationships = search(maleGenderParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(3));
List<RelatedPerson> relationList = get(relationships);
assertThat(relationList, hasSize(equalTo(3)));
assertThat(relationList, everyItem(hasProperty("gender", equalTo(Enumerations.AdministrativeGender.MALE))));
gender = new TokenAndListParam().addAnd(new TokenOrListParam().add(FEMALE_GENDER));
SearchParameterMap femaleGenderParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, gender);
relationships = search(femaleGenderParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(2));
relationList = get(relationships);
assertThat(relationList, hasSize(equalTo(2)));
assertThat(relationList, everyItem(hasProperty("gender", equalTo(Enumerations.AdministrativeGender.FEMALE))));
gender = new TokenAndListParam().addAnd(new TokenOrListParam().add(OTHER_GENDER));
SearchParameterMap otherGenderParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, gender);
relationships = search(otherGenderParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(2));
relationList = get(relationships);
assertThat(relationList, hasSize(equalTo(2)));
assertThat(relationList, everyItem(hasProperty("gender", equalTo(null))));
gender = new TokenAndListParam().addAnd(new TokenOrListParam().add(NULL_GENDER));
SearchParameterMap nullGenderParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, gender);
relationships = search(nullGenderParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(2));
relationList = get(relationships);
assertThat(relationList, hasSize(equalTo(2)));
assertThat(relationList, everyItem(hasProperty("gender", equalTo(null))));
gender = new TokenAndListParam().addAnd(new TokenOrListParam().add(UNKNOWN_GENDER));
SearchParameterMap unknownGenderParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, gender);
relationships = search(unknownGenderParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(2));
relationList = get(relationships);
assertThat(relationList.size(), equalTo(2));
assertThat(relationList, everyItem(hasProperty("gender", equalTo(null))));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnBirthDate.
@Test
public void shouldReturnEmptyCollectionForNoMatchOnBirthDate() {
DateRangeParam dateRangeParam = new DateRangeParam().setLowerBound(NOT_FOUND_BIRTH_DATE).setUpperBound(NOT_FOUND_BIRTH_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, dateRangeParam);
IBundleProvider relationships = search(theParams);
assertThat(relationships, notNullValue());
assertThat(relationships.size(), equalTo(0));
List<RelatedPerson> relationList = get(relationships);
assertThat(relationList, empty());
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelationForMatchOnBirthDateofRelatedPerson.
@Test
public void shouldReturnCollectionOfRelationForMatchOnBirthDateofRelatedPerson() {
DateRangeParam dateRangeParam = new DateRangeParam().setLowerBound(BIRTH_DATE).setUpperBound(BIRTH_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, dateRangeParam);
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).getBirthDate().toString(), startsWith(BIRTH_DATE));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleForMatchOnPostalCode.
@Test
public void shouldReturnCollectionOfRelatedPeopleForMatchOnPostalCode() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_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().getPostalCode(), equalTo(POSTAL_CODE));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByPostalCode.
@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByPostalCode() {
StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(postalCodeParam)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, postalCodeParam, 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