Search in sources :

Example 96 with RelatedPerson

use of org.hl7.fhir.dstu3.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))));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 97 with RelatedPerson

use of org.hl7.fhir.dstu3.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());
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 98 with RelatedPerson

use of org.hl7.fhir.dstu3.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));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 99 with RelatedPerson

use of org.hl7.fhir.dstu3.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));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 100 with RelatedPerson

use of org.hl7.fhir.dstu3.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)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)87 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)54 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)51 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)29 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)24 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)24 StringParam (ca.uhn.fhir.rest.param.StringParam)24 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)20 RelatedPerson (org.hl7.fhir.dstu3.model.RelatedPerson)17 Test (org.junit.jupiter.api.Test)17 Resource (org.hl7.fhir.r4.model.Resource)14 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)13 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)12 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)12 Patient (org.hl7.fhir.r4.model.Patient)12 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)11 Identifier (org.hl7.fhir.r4.model.Identifier)10 Reference (org.hl7.fhir.r4.model.Reference)9