Search in sources :

Example 96 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class UserSearchQueryTest method searchForUsers_shouldReturnUsersByCity.

@Test
public void searchForUsers_shouldReturnUsersByCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringParam(CITY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(ADDRESS_SEARCH_HANDLER, CITY_PROPERTY, city);
    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().getCity(), equalTo(CITY));
}
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 97 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class SearchParameterMapTest method shouldAddStringOrListParamIntoTheMap.

@Test
public void shouldAddStringOrListParamIntoTheMap() {
    StringOrListParam orListParam = new StringOrListParam();
    orListParam.addOr(new StringParam("Clement"));
    searchParam.addParameter(NAME, orListParam);
    assertThat(searchParam, notNullValue());
    assertThat(searchParam.getParameters(NAME), not(empty()));
    assertThat(searchParam.getParameters(NAME), hasSize(is(1)));
}
Also used : StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Test(org.junit.Test)

Example 98 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class SearchParameterMapTest method shouldAddStringAndListParamIntoTheMap.

@Test
public void shouldAddStringAndListParamIntoTheMap() {
    StringAndListParam andListParam = new StringAndListParam();
    andListParam.addAnd(new StringParam("John"));
    searchParam.addParameter(NAME, andListParam);
    assertThat(searchParam, notNullValue());
    assertThat(searchParam.getParameters(NAME), not(empty()));
    assertThat(searchParam.getParameters(NAME), hasSize(is(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) StringParam(ca.uhn.fhir.rest.param.StringParam) Test(org.junit.Test)

Example 99 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class SearchParameterMapTest method shouldAddStringAndListParamIntoAnExistingMapUsingTheSameKeyValue.

@Test
public void shouldAddStringAndListParamIntoAnExistingMapUsingTheSameKeyValue() {
    StringAndListParam andListParam1 = new StringAndListParam();
    andListParam1.addAnd(new StringParam("John"));
    StringAndListParam andListParam2 = new StringAndListParam();
    andListParam2.addAnd(new StringParam("Joe"));
    searchParam.addParameter(NAME, andListParam1);
    searchParam.addParameter(NAME, andListParam2);
    assertThat(searchParam, notNullValue());
    assertThat(searchParam.getParameters(NAME), not(empty()));
    assertThat(searchParam.getParameters(NAME), hasSize(is(2)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) StringParam(ca.uhn.fhir.rest.param.StringParam) Test(org.junit.Test)

Example 100 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project elexis-server by elexis.

the class PersonResourceProvider method search.

@Search
public List<Person> search(@OptionalParam(name = Person.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
    IQuery<IPerson> query = modelService.getQuery(IPerson.class);
    if (name != null) {
        QueryUtil.andContactNameCriterion(query, name);
    }
    if (theFtFilter != null) {
        new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
    }
    List<IPerson> persons = query.execute();
    List<Person> _persons = persons.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    return _persons;
}
Also used : IdParam(ca.uhn.fhir.rest.annotation.IdParam) IFhirTransformerRegistry(ch.elexis.core.findings.util.fhir.IFhirTransformerRegistry) IFhirTransformer(ch.elexis.core.findings.util.fhir.IFhirTransformer) LoggerFactory(org.slf4j.LoggerFactory) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Update(ca.uhn.fhir.rest.annotation.Update) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IModelService(ch.elexis.core.services.IModelService) Component(org.osgi.service.component.annotations.Component) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Search(ca.uhn.fhir.rest.annotation.Search) IContactSearchFilterQueryAdapter(es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter) Delete(ca.uhn.fhir.rest.annotation.Delete) Activate(org.osgi.service.component.annotations.Activate) Person(org.hl7.fhir.r4.model.Person) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Read(ca.uhn.fhir.rest.annotation.Read) Logger(org.slf4j.Logger) Create(ca.uhn.fhir.rest.annotation.Create) IPerson(ch.elexis.core.model.IPerson) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) IQuery(ch.elexis.core.services.IQuery) List(java.util.List) ResourceParam(ca.uhn.fhir.rest.annotation.ResourceParam) QueryUtil(es.fhir.rest.core.resources.util.QueryUtil) StringParam(ca.uhn.fhir.rest.param.StringParam) Optional(java.util.Optional) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) Reference(org.osgi.service.component.annotations.Reference) IPerson(ch.elexis.core.model.IPerson) Optional(java.util.Optional) IContactSearchFilterQueryAdapter(es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter) Person(org.hl7.fhir.r4.model.Person) IPerson(ch.elexis.core.model.IPerson) Search(ca.uhn.fhir.rest.annotation.Search)

Aggregations

StringParam (ca.uhn.fhir.rest.param.StringParam)271 Test (org.junit.Test)251 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)248 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)243 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)173 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)154 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)116 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)101 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)37 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)30 Practitioner (org.hl7.fhir.r4.model.Practitioner)26 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)21 Patient (org.hl7.fhir.r4.model.Patient)21 TokenParam (ca.uhn.fhir.rest.param.TokenParam)20 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)18 NumberParam (ca.uhn.fhir.rest.param.NumberParam)16 Observation (org.hl7.fhir.r4.model.Observation)16 Location (org.hl7.fhir.r4.model.Location)14 Person (org.hl7.fhir.r4.model.Person)14 SortSpec (ca.uhn.fhir.rest.api.SortSpec)13