Search in sources :

Example 51 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByGender.

@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByGender() {
    TokenAndListParam genderParam = new TokenAndListParam().addAnd(new TokenOrListParam().add(GENDER));
    when(relatedPersonService.searchForRelatedPeople(isNull(), argThat(is(genderParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchRelatedPerson(null, genderParam, null, null, null, null, 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 : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 52 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByCity.

@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByCity() {
    StringAndListParam cityParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
    when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), argThat(is(cityParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, cityParam, null, null, 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)

Example 53 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByCountry.

@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByCountry() {
    StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
    when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(countryParam)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, null, countryParam, 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)

Example 54 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByLastUpdated.

@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByLastUpdated() {
    DateRangeParam lastUpdated = new DateRangeParam().setLowerBound(LAST_UPDATED_DATE).setUpperBound(LAST_UPDATED_DATE);
    when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(lastUpdated)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, null, null, null, lastUpdated, 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 : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 55 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByState.

@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByState() {
    StringAndListParam stateParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
    when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), argThat(is(stateParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, stateParam, null, 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