Search in sources :

Example 26 with Practitioner

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

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByAddressCity.

@Test
public void shouldSearchForPractitionersByAddressCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringParam(CITY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, city, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    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) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 27 with Practitioner

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

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByAddressState.

@Test
public void shouldSearchForPractitionersByAddressState() {
    StringAndListParam state = new StringAndListParam().addAnd(new StringParam(STATE));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, state);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, null, state, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    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) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 28 with Practitioner

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

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByLastUpdated.

@Test
public void shouldSearchForPractitionersByLastUpdated() {
    DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, null, null, null, null, null, lastUpdated, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    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) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 29 with Practitioner

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

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByAddressCountry.

@Test
public void shouldSearchForPractitionersByAddressCountry() {
    StringAndListParam country = new StringAndListParam().addAnd(new StringParam(COUNTRY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, country);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, null, null, null, country, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    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) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 30 with Practitioner

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

the class FhirPractitionerServiceImplTest method setUp.

@Before
public void setUp() {
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    practitionerService = new FhirPractitionerServiceImpl();
    practitionerService.setDao(practitionerDao);
    practitionerService.setTranslator(practitionerTranslator);
    practitionerService.setSearchQuery(searchQuery);
    practitionerService.setUserService(userService);
    practitionerService.setSearchQueryInclude(searchQueryInclude);
    practitionerService.setGlobalPropertyService(globalPropertyService);
    provider = new Provider();
    provider.setUuid(UUID);
    provider.setRetired(false);
    provider.setName(NAME);
    provider.setIdentifier(IDENTIFIER);
    practitioner = new Practitioner();
    practitioner.setId(UUID);
    practitioner.setIdentifier(Collections.singletonList(new Identifier().setValue(IDENTIFIER)));
    practitioner.setActive(false);
    practitioner2 = new Practitioner();
    practitioner2.setId(UUID2);
    practitioner2.setIdentifier(Collections.singletonList(new Identifier().setValue(USER_SYSTEM_ID)));
    practitioner2.setActive(false);
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Identifier(org.hl7.fhir.r4.model.Identifier) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) Provider(org.openmrs.Provider) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) SearchQueryBundleProvider(org.openmrs.module.fhir2.api.search.SearchQueryBundleProvider) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)185 Practitioner (org.hl7.fhir.r4.model.Practitioner)139 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)86 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)81 Test (org.junit.jupiter.api.Test)68 Practitioner (org.hl7.fhir.dstu3.model.Practitioner)62 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)59 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)54 StringParam (ca.uhn.fhir.rest.param.StringParam)54 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)52 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)37 Identifier (org.hl7.fhir.r4.model.Identifier)32 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)30 Resource (org.hl7.fhir.r4.model.Resource)30 ArrayList (java.util.ArrayList)25 Reference (org.hl7.fhir.r4.model.Reference)24 Bundle (org.hl7.fhir.r4.model.Bundle)22 Date (java.util.Date)21 List (java.util.List)21 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)20