Search in sources :

Example 46 with Practitioner

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

the class UserSearchQueryTest method searchForUsers_shouldSearchForUsersByLastUpdatedDateChanged.

@Test
public void searchForUsers_shouldSearchForUsersByLastUpdatedDateChanged() {
    DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CHANGED).setLowerBound(DATE_CHANGED);
    SearchParameterMap theParams = new SearchParameterMap().addParameter(COMMON_SEARCH_HANDLER, LAST_UPDATED_PROPERTY, lastUpdated);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(1));
    List<Practitioner> resultList = get(results);
    assertThat(resultList, hasSize(equalTo(1)));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Practitioner(org.hl7.fhir.r4.model.Practitioner) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 47 with Practitioner

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

the class UserSearchQueryTest method searchForUsers_shouldReturnUsersByFamilyName.

@Test
public void searchForUsers_shouldReturnUsersByFamilyName() {
    StringAndListParam familyName = new StringAndListParam().addAnd(new StringParam(USER_FAMILY_NAME));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, FAMILY_PROPERTY, familyName);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThanOrEqualTo(1));
    List<Practitioner> resultList = get(results);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList, everyItem(hasProperty("name", hasItem(hasProperty("family", equalTo(USER_FAMILY_NAME))))));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 48 with Practitioner

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

the class UserSearchQueryTest method searchForUsers_shouldReturnUsersByMatchingGivenAndFamilyName.

@Test
public void searchForUsers_shouldReturnUsersByMatchingGivenAndFamilyName() {
    StringAndListParam givenName = new StringAndListParam().addAnd(new StringParam(USER_GIVEN_NAME));
    StringAndListParam familyName = new StringAndListParam().addAnd(new StringParam(USER_FAMILY_NAME));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, GIVEN_PROPERTY, givenName).addParameter(NAME_SEARCH_HANDLER, FAMILY_PROPERTY, familyName);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThanOrEqualTo(1));
    List<Practitioner> resultList = get(results);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList, everyItem(hasProperty("name", hasItem(hasProperty("given", hasItem(hasProperty("value", equalTo(USER_GIVEN_NAME))))))));
    assertThat(resultList, everyItem(hasProperty("name", hasItem(hasProperty("family", equalTo(USER_FAMILY_NAME))))));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 49 with Practitioner

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

the class UserSearchQueryTest method searchForUsers_shouldReturnEmptyCollectionByWrongCity.

@Test
public void searchForUsers_shouldReturnEmptyCollectionByWrongCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringParam(WRONG_CITY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(0));
    List<Practitioner> resultList = get(results);
    assertThat(resultList, empty());
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 50 with Practitioner

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

the class UserSearchQueryTest method searchForUsers_shouldReturnUsersByCountry.

@Test
public void searchForUsers_shouldReturnUsersByCountry() {
    StringAndListParam country = new StringAndListParam().addAnd(new StringParam(COUNTRY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(ADDRESS_SEARCH_HANDLER, COUNTRY_PROPERTY, country);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThanOrEqualTo(1));
    List<Practitioner> resultList = get(results);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getAddressFirstRep().getCountry(), equalTo(COUNTRY));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

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